Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
handle y2k38 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chpeck@thingbuzz.com authored and dwaite committed Aug 29, 2010
1 parent 7fcc600 commit f29fd1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/cookiejar/cookie_validation.rb
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/cookie_validation_test.rb
Expand Up @@ -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.