Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 23811
Status: resolved
Worked: -1920 min
Priority: 0/
Queue: CGI

People
Owner: LDS [...] cpan.org
Requestors: brian [...] wightmanfam.org
Cc:
AdminCc:

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



Subject: CGI.pm-3.25 - CGI::Util::expire_calc fails to handle seconds notation
Date: Tue, 5 Dec 2006 10:33:26 -0800 (PST)
To: bug-CGI.pm [...] rt.cpan.org
From: "Brian T. Wightman" <brian [...] wightmanfam.org>
If you pass a time period of /[-+]\d+s/ to CGI::Util::expire_calc, it will return the original string, instead of the proper timestamp. Bug was tickled by test cases in CGI-Application-Plugin-Session-1.02, but was traced back to CGI.pm-3.25. Here is the test: ============= t/util-expirecalc.t ============= #!/usr/local/bin/perl -w # Test timestamp specifiers in comments in CGI::Util::expire_calc ######################### We start with some black magic to print on failure. use lib '../blib/lib','../blib/arch'; BEGIN {$| = 1; print "1..10\n"; } END {print "not ok 1\n" unless $loaded;} use Config; use CGI::Util qw(escape unescape); $loaded = 1; print "ok 1\n"; ######################### End of black magic. # util sub test { local($^W) = 0; my($num, $true,$msg) = @_; print($true ? "ok $num\n" : "not ok $num $msg\n"); } # Specifies offsets from the current time my %tests = ( "now" => 0, "+180s" => 180, "+2m" => 2 * 60, "+12h" => 12 * 60 * 60, "+1d" => 24 * 60 * 60, "+3M" => 3 * 30 * 24 * 60 * 60, "+2y" => 2 * 365 * 24 * 60 * 60, "-3m" => -3 * 60, ); my $i = 1; foreach(sort(keys(%tests))) { $i++; test($i, ($tests{$_}+time()) == CGI::Util::expire_calc($_) , "# $_ != expire_calc($_)"); } print "ok 10\n"; ============== End ============== And the patch: ============== CGI.pm-3.25-patch-000 ============== *** CGI/Util.pm.orig Tue Dec 5 12:23:44 2006 --- CGI/Util.pm Tue Dec 5 12:24:12 2006 *************** *** 261,267 **** $offset = 0; } elsif ($time=~/^\d+/) { return $time; ! } elsif ($time=~/^([+-]?(?:\d+|\d*\.\d*))([mhdMy])/) { $offset = ($mult{$2} || 1)*$1; } else { return $time; --- 261,267 ---- $offset = 0; } elsif ($time=~/^\d+/) { return $time; ! } elsif ($time=~/^([+-]?(?:\d+|\d*\.\d*))([smhdMy])/) { $offset = ($mult{$2} || 1)*$1; } else { return $time; ============== End ==============
Applied patch and fix will appear in version 3.26.