Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP::Cookie: parse max-age as Int64, not Int32 #8759

Merged
merged 2 commits into from
Feb 8, 2020

Conversation

asterite
Copy link
Member

@asterite asterite commented Feb 7, 2020

Fixes #8744

I considered parsing it as UInt64 too, but if max-age is Int64::MAX it already overflows when trying to create a time instance, so Int64 is probably fine.

(or put another way, in the rare case it breaks with a much bigger number let's tackle that later)

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:networking labels Feb 7, 2020
it "parses large max-age (#8744)" do
cookie = parse_set_cookie("a=1; max-age=3153600000")
delta = cookie.expires.not_nil! - Time.utc
delta.should be > (3153600000 - 1).seconds
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use be_close expectation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the code from the previous spec without too much thought.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to use be_close

@asterite asterite merged commit 3b14de7 into master Feb 8, 2020
@asterite asterite added this to the 0.33.0 milestone Feb 8, 2020
@asterite asterite deleted the bug/cookie-max-age-overflow branch February 8, 2020 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP::Client::Response.cookies Invalid Int32 (ArgumentError)
2 participants