Skip Menu |

This queue is for tickets about the XML-FeedPP CPAN distribution.

Report information
The Basics
Id: 71318
Status: resolved
Priority: 0/
Queue: XML-FeedPP

People
Owner: Nobody in particular
Requestors: gomesbascoy [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: timegm is not evaluated
Date: Wed, 28 Sep 2011 15:11:06 -0300
To: bug-xml-feedpp [...] rt.cpan.org
From: Brian Gomes Bascoy <gomesbascoy [...] gmail.com>
You must eval everytime that Time::Local::timegm is used, otherwise wrong dates could crash the program. For example day 42 or hour 24 will return the following error messages and stop the execution: Day '42' out of range 1..31 [...] Hour '24' out of range 0..23 [...] Here is the patch for version 0.43: --- FeedPP.pm 2011-09-28 13:06:18.899289158 -0300 +++ FeedPP.pm-patched 2011-09-28 15:03:42.747610254 -0300 @@ -2401,8 +2401,7 @@ @MoY = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); @MoY{ map { uc($_) } @MoY } = ( 1 .. 12 ); my $tz_now = time(); -my $tz_offset = Time::Local::timegm( localtime($tz_now) ) - - Time::Local::timegm( gmtime($tz_now) ); +my $tz_offset = eval { Time::Local::timegm( localtime($tz_now) ) - Time::Local::timegm( gmtime($tz_now) ); }; my $tz_hour = int( $tz_offset / 3600 ); my $tz_min = int( $tz_offset / 60 ) % 60; my $rfc1123_regexp = qr{ @@ -2468,7 +2467,8 @@ $hour ||= 0; $min ||= 0; $sec ||= 0; - my $epoch = Time::Local::timegm( $sec, $min, $hour, $mday, $mon-1, $year-1900 ); + my $epoch = eval { Time::Local::timegm( $sec, $min, $hour, $mday, $mon-1, $year-1900 ); } + or return; my $wday = ( gmtime($epoch) )[6]; if ( defined $tz && $tz ne '' && $tz ne 'Z' ) { my $off = &get_tz_offset($tz) / 60; @@ -2491,7 +2491,8 @@ $year += 2000 if $year < 77; $year += 1900 if $year < 100; $mon = $MoY{ uc($mon) } or return; - my $epoch = Time::Local::timegm( $sec, $min, $hour, $mday, $mon-1, $year-1900 ); + my $epoch = eval { Time::Local::timegm( $sec, $min, $hour, $mday, $mon-1, $year-1900 ); } + or return; $epoch -= &get_tz_offset( $tz ); $epoch; } @@ -2504,7 +2505,8 @@ $hour ||= 0; $min ||= 0; $sec ||= 0; - my $epoch = Time::Local::timegm( $sec, $min, $hour, $mday, $mon-1, $year-1900 ); + my $epoch = eval { Time::Local::timegm( $sec, $min, $hour, $mday, $mon-1, $year-1900 ); } + or return; $epoch -= &get_tz_offset( $tz ); $epoch; }
taken in release 0.95