[PATCH] Y2K Problem with HTTP::Date (libwww-5.42)
W. Phillip Moore (wpm@ms.com)
Tue, 20 Apr 1999 15:15:59 -0400 (EDT)
I *just* sent the request to subscribe to this list, so with my luck,
this has been discussed verbosely in just the last day or two. A quick
search of the recent discussions on the hypermail archive didn't
reveal anything.
I am responsible for taking our entire perl5 infrastructure through
rather thorough Y2K testing, and I've discovered a problem with the
HTTP::Date::str2time() routine, and the t/cookies.t test suite.
Since I'm assessing and testing over 4,000,000 lines of code from
CPAN, I'm not reinventing the wheel whenit comes to test suites, and
I'm depending on the ones provided with the code. I'm running the
tests using todays date, as well as 1/3/2000 and 2/29/2000.
In the case of libwww-5.42, the test suites blow up when run in the
year 2000.
t/cookies.t creates a cookie with the expiration date of 11/9/1999, so
it starts out expired. Bummer. The patch in this case just bumps the
date up by a year.
HTTP::Date::str2time() blow up when few a date string which does NOT
include the year explicitly. The code defaults to the current year
supplied by localtime (100), and then promply returns undef:
return undef if $yr > 99 && $yr < 1900; # We ignore these years
Bummer again. My simple solution was to allow at least up to 138,
which will get us by until 32-but UNIX time runs out. I'll be retired
by then ;-)
return undef if $yr > 138 && $yr < 1900; # We ignore these years
These trivial changes allow the libwww-5.42 test suite to pass all of
its test for the 3 dates I listed above.
W. Phillip Moore Phone: 212-762-2433
Vice President, Infrastructure Development FAX: 212-762-0174
Morgan Stanley Dean Witter E-mail: wpm@ms.com
750 7th Ave, NY, NY 10019
diff -rc libwww-perl-5.42-orig/lib/HTTP/Date.pm libwww-perl-5.42/lib/HTTP/Date.pm
*** libwww-perl-5.42-orig/lib/HTTP/Date.pm Thu Feb 12 18:13:47 1998
--- libwww-perl-5.42/lib/HTTP/Date.pm Tue Apr 20 14:55:03 1999
***************
*** 265,272 ****
$yr-- if $mon > $current_month;
}
# Then we check if the year is acceptable
! return undef if $yr > 99 && $yr < 1900; # We ignore these years
$yr += 100 if $yr < 50; # a stupid thing to do???
$yr -= 1900 if $yr >= 1900;
# The $yr is now relative to 1900 (as expected by timelocal())
--- 265,280 ----
$yr-- if $mon > $current_month;
}
+ #
+ # XXX (wpm@ms.com) -- the original code ignored $yr > 99, but if
+ # the year isn't supplied, and we default to the current year then
+ # it is >= 2000, we get $yr == 100.
+ #
+ # return undef if $yr > 99 && $yr < 1900; # We ignore these years
+ #
+
# Then we check if the year is acceptable
! return undef if $yr > 138 && $yr < 1900; # We ignore these years
$yr += 100 if $yr < 50; # a stupid thing to do???
$yr -= 1900 if $yr >= 1900;
# The $yr is now relative to 1900 (as expected by timelocal())
diff -rc libwww-perl-5.42-orig/t/base/cookies.t libwww-perl-5.42/t/base/cookies.t
*** libwww-perl-5.42-orig/t/base/cookies.t Fri Apr 10 08:30:37 1998
--- libwww-perl-5.42/t/base/cookies.t Tue Apr 20 13:59:04 1999
***************
*** 48,54 ****
$res = HTTP::Response->new(200, "OK");
$res->request($req);
! $res->header("Set-Cookie" => "CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT");
$c->extract_cookies($res);
$req = HTTP::Request->new(GET => "http://www.acme.com/");
--- 48,55 ----
$res = HTTP::Response->new(200, "OK");
$res->request($req);
! #$res->header("Set-Cookie" => "CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT");
! $res->header("Set-Cookie" => "CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-00 23:12:40 GMT");
$c->extract_cookies($res);
$req = HTTP::Request->new(GET => "http://www.acme.com/");