Fix a bug where cookies with Max-Age too big are not stored#1094
Fix a bug where cookies with Max-Age too big are not stored#1094rbri merged 1 commit intoHtmlUnit:masterfrom
Conversation
|
|
@duonglaiquang will work on that later today, maybe i can add a unit test. @duonglaiquang do you need a release for all that? As i'm working towards 5.0, no 4.x releases are planned and the 5.0 might need some more time. and last - have you seen my email? |
|
@rbri Thank you very much. |
|
hope the java17 move is ok for you |
|
Oh I didn't realise we'd upstreamed all these PRs 😅 Cool 👍
@rbri |
|
@atnak - see https://github.com/HtmlUnit/htmlunit/blob/master/src/changes/changes.xml there are hopefully many more good reasons to move ;-) |



This PR does the following
Fix
HtmlUnitMaxAgeHandlerto correctly handle cookies with large, negative, or non-numericmax-agevalues per RFC 6265.Problem
When a server sends a cookie with a
max-agevalue that exceedsInteger.MAX_VALUE(e.gmax-age=99999999999),Integer.parseIntthrowsNumberFormatException, which is wrapped intoMalformedCookieException, causing the entire cookie to be rejected.Per RFC 6265, large values should be capped to a limit (400 days) rather than rejected.
Additionally, negative/zero delta-seconds should set expiry to the earliest representable date instead of offsetting current time.