Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/Date/Manip/Date.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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'};
Expand Down Expand Up @@ -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'}) {
Expand Down