Skip to content

fix: accept zero-offset Cookie Expires dates - #1493

Merged
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/cookie-expires-zero-offset
Nov 18, 2026
Merged

He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/cookie-expires-zero-offset

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Motivation

Cookie Expires dates can use the zero UTC offset -0000. Accept it in the date layouts already supported by the cookie parser.

Modification

Recognize -0000 only in the existing Cookie Expires representations, consistent with RFC 6265 section 5.1.1 interpreting the resulting date in UTC. Keep shared HTTP-Date parsing, validation and fallback behavior unchanged. Add positive cases including canonical GMT rendering and preservation of Path.

Result

Supported cookie dates with -0000 are accepted without broadening other HTTP date parsing. This is not complete RFC 6265 date-parser support.

Tests

Five selected cases failed as expected against the exact baseline; fourteen selected final positive cases passed against cached modules. Strict compilation, targeted MiMa with zero findings and git diff --check passed. Full repository CI was not run.

References

None - context: RFC 6265 section 5.1.1 and Netty 4.2 edc48423 as a test pointer. The Pekko implementation was written independently.

Motivation:
Legacy cookie expiry dates may specify UTC as -0000. The existing
cookie date rules do not recognize this suffix.

Modification:
Extend only the cookie date rules to accept -0000. Try those rules before
the shared HTTP-date rule so a supported asctime prefix does not leave the
suffix unconsumed. Add positive format, canonical rendering and subsequent
Path attribute coverage, and document the scoped receiver compatibility.

Result:
Supported cookie expiry formats retain their UTC value and following
attributes. Shared HTTP date rules and existing cookie validation remain
unchanged. This is not a full RFC 6265 token-parser implementation.

Tests:
- Five positive zero-offset cases fail against exact baseline rules.
- All 14 selected positive cases pass against the final rules.
- Scala 2.13.18 production compile with deprecation/import warnings fatal.
- Focused MiMa 1.2.1 comparison; cached support classes, not a full build.
- Scalafmt 3.11.5 and git diff --check pass.
- Full sbt, Scala 3, Paradox and aggregate MiMa not run in this offline check.

References:
None - RFC 6265 sections 5.1.1 and 5.2.1; independent implementation
informed by Netty commit edc4842309ad0491b7f2088c8116318b3d680db8.
@He-Pin
He-Pin requested a balanced review from Copilot November 18, 2026 06:51
@He-Pin
He-Pin marked this pull request as ready for review November 18, 2026 06:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active issues remain, and the change is narrowly scoped to RFC 6265-compatible cookie date parsing with focused regression coverage and documentation.

No open issues 🎉

Review effort: Lite

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Nits:

  • The sentence added to client-side/request-level.md (Collecting headers) feels out of place there, and the note about HTTP Date/Expires parsing is an internal detail. I'd drop the docs change.
  • The PR description says the space-padded asctime day is unsupported, but date3 already accepts ' ' ~ digit, so Sun Nov 6 08:09:07 1994 should parse.

@He-Pin
He-Pin merged commit 15ea3c5 into apache:main Nov 18, 2026
6 checks passed
@He-Pin
He-Pin deleted the fix/cookie-expires-zero-offset branch November 18, 2026 09:14
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.

3 participants