SBECK-github / Date-Manip

Other
10 stars 11 forks source link

Infinite loop for invalid frequency values in Date::Manip::Recur #7

Closed albhilazo closed 8 years ago

albhilazo commented 8 years ago

Hi,

While using Date::Manip::Recur I have found that invalid values (not syntax) in a frequency string are not controlled, which breaks the calculation of recurring events.

I have been able to test it in two versions with different results: current 6.54 version and older 6.43. I'm aware that 6.43 is quite old, but it could help you reproduce the error.

Example:

For the frequency string: '0:1*1,4,7:0:0:0:0' (there's no week 7) With any base date and range. When calling $recur->next();.

Using version 6.43, dies with:

Use of uninitialized value $n in integer subtraction (-) at Date/Manip/Recur.pm line 763.

Using version 6.54, falls in an infinite loop with output:

Use of uninitialized value $beg in string comparison (cmp) at Date/Manip/TZ.pm line 1355.
Use of uninitialized value $end in string comparison (cmp) at Date/Manip/TZ.pm line 1357.

Example code (perl 5.16.3):

use Date::Manip::Recur;
my $recur = new Date::Manip::Recur;

$recur->parse( '0:1*1,4,7:0:0:0:0' );
$recur->basedate( '2016-06-06T16:00:00' );
$recur->start( '2016-06-06T16:00:00' );
$recur->end( '2019-06-06T16:00:00' );

$recur->next();

Is there any way to control invalid frequencies like this one?

Thanks!

SBECK-github commented 8 years ago

I actually thought I already checked for invalid values... apparently I missed something. I'll investigate and make sure it gets fixed in the next release.

SBECK-github commented 8 years ago

This is now fixed in github and will be in the next release.

albhilazo commented 8 years ago

That was fast!

Thanks!

albhilazo commented 8 years ago

By the way, do you have any release date in mind? (just to know how I can manage it)

SBECK-github commented 8 years ago

Date::Manip is released quarterly (to handle timezone changes). I actually just did a release 1 week ago, so the next is scheduled in nearly 3 months on Sep 1.