Skip to content

Add tests for mismatched weekdays in cookie Expires dates - #949

Merged
ok2c merged 1 commit into
apache:masterfrom
DicksonWu654:cookie-expires-weekday
Nov 19, 2026
Merged

ok2c merged 1 commit into
apache:masterfrom
DicksonWu654:cookie-expires-weekday

Conversation

@DicksonWu654

@DicksonWu654 DicksonWu654 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

RFC 6265 section 5.1.1 parses a cookie date from its time, day-of-month, month and year tokens and never compares the weekday name against the date. In StandardCookieSpec.RELAXED mode RFC6265LaxSpec uses LaxExpiresHandler, which follows that algorithm and ignores the weekday. In StandardCookieSpec.STRICT mode BasicExpiresHandler with DateUtils.STANDARD_PATTERNS checks it, so Expires=Mon, 01 Jan 2030 00:00:00 GMT (a Tuesday) is rejected.

Per review, STRICT keeps that behavior, so this PR only adds tests that pin both modes: STRICT (and BasicExpiresHandler) reject a mismatched weekday, and RELAXED accepts it and sets the expiry to 2030-01-01T00:00:00Z.

This was the third of the three cookie items from the dev@hc.apache.org thread.

./mvnw -pl httpclient5 -am verify on master (900bcb9) passes: 1166 tests, with Checkstyle and RAT passing.

@ok2c

ok2c commented Nov 18, 2026

Copy link
Copy Markdown
Member

@DicksonWu654 Please rebase off the latest master.

@DicksonWu654

Copy link
Copy Markdown
Contributor Author

Done, rebased onto master! Full httpclient5 verify passes locally

@DicksonWu654
DicksonWu654 force-pushed the cookie-expires-weekday branch from 2905ccb to c045e98 Compare November 18, 2026 18:02
@ok2c

ok2c commented Nov 18, 2026

Copy link
Copy Markdown
Member

@DicksonWu654 Do you think we could make this logic conditional on StandardCookieSpec parameter? Could we keep the current behavior for the StandardCookieSpec.STRICT mode and use the lenient parser you have introduced in StandardCookieSpec.RELAXED mode?

@DicksonWu654
DicksonWu654 force-pushed the cookie-expires-weekday branch from c045e98 to 0befc7e Compare November 18, 2026 22:04
@DicksonWu654 DicksonWu654 changed the title Ignore mismatched weekdays in cookie Expires dates Add tests for mismatched weekdays in cookie Expires dates Nov 18, 2026
@DicksonWu654

Copy link
Copy Markdown
Contributor Author

Good call! Turns out RELAXED already does this - it uses LaxExpiresHandler, which ignores the weekday. So with STRICT unchanged there's nothing left to change in the parser.

I've cut the PR down to tests that pin both behaviors: STRICT rejects a mismatched weekday, RELAXED accepts it and sets the expiry. Full httpclient5 verify passes. Happy to close it instead if you'd rather not carry the extra tests

@ok2c
ok2c merged commit 43a2f5a into apache:master Nov 19, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants