diff --git a/lib/Date/Manip/Date.pm b/lib/Date/Manip/Date.pm index bcc762c9f..455cedbc5 100644 --- a/lib/Date/Manip/Date.pm +++ b/lib/Date/Manip/Date.pm @@ -94,6 +94,13 @@ sub input { # DATE PARSING ######################################################################## +# The longest string the parsers will look at. The time matching +# regexp is applied unanchored, so the cost of failing to match grows +# with the square of the length of an interior whitespace run. Real +# date strings are well under 100 characters. + +our $MAXLENGTH = 256; + sub parse { my($self,$instring,@opts) = @_; $self->_init(); @@ -104,6 +111,11 @@ sub parse { return 1; } + if (length($instring) > $MAXLENGTH) { + $$self{'err'} = '[parse] Date string too long'; + return 1; + } + my %opts = map { $_,1 } @opts; my $dmt = $$self{'tz'}; @@ -382,6 +394,11 @@ sub parse_time { return 1; } + if (length($string) > $MAXLENGTH) { + $$self{'err'} = '[parse_time] Time string too long'; + return 1; + } + my($y,$m,$d,$h,$mn,$s); if ($$self{'err'}) {