Permalink
Browse files

handle y2k38 bug

  • Loading branch information...
1 parent 7fcc600 commit f29fd1c79ef79f977240ce97f96d6e7db9b52f0b chpeck@thingbuzz.com committed with Jul 8, 2010
Showing with 11 additions and 1 deletion.
  1. +6 −1 lib/cookiejar/cookie_validation.rb
  2. +5 −0 test/cookie_validation_test.rb
@@ -308,7 +308,12 @@ def self.parse_set_cookie set_cookie_value
else
case key
when :expires
- args[:expires_at] = Time.parse keyvalue
+ begin
+ args[:expires_at] = Time.parse keyvalue
+ rescue ArgumentError
+ raise unless $!.message == "time out of range"
+ args[:expires_at] = Time.at(0x7FFFFFFF)
+ end
when *[:domain, :path]
args[key] = keyvalue
when :secure
@@ -236,4 +236,9 @@
end
end
end
+ describe '#parse_set_cookie' do
+ it "should max out at 2038 on 32bit systems" do
+ CookieValidation.parse_set_cookie("TRACK_USER_P=98237480810003948000782774;expires=Sat, 30-Jun-2040 05:39:49 GMT;path=/")[:expires_at].to_i.should >= 0x7FFFFFFF
+ end
+ end
end

0 comments on commit f29fd1c

Please sign in to comment.