Repository navigation
Accept single-digit time components in cookie expiry dates - #1458
Merged
Merged
Conversation
pjfanning
reviewed
Nov 17, 2026
pjfanning
left a comment
Member
There was a problem hiding this comment.
Thanks, this looks correct. Trying HTTP-date first and only then the cookie-specific shapes keeps canonical dates on the existing path. Scoping it to expires-av leaves Date/Expires headers strict, and the tests show that. Two minor points:
- Duplicated rules.
cookie-IMF-fixdateandcookie-asctime-dateare copies ofIMF-fixdateandasctime-datethat differ only in usingcookie-time-of-day. That's fine for now, but a comment on the originals pointing at the cookie variants (or vice versa) would help keep them in sync if the date shapes change again. - Behaviour change for invalid single-digit dates. Previously a cookie like
Expires=Sun, 06 Nov 1994 24:0:0 GMTfell through to theDateTime.MinValuefallback and theSet-Cookiewas still modeled. Now it reachescreateDateTimevalidation and the whole header becomes aRawHeaderwith errors. That's consistent with how the two-digit form already behaves, and the description mentions it, but it might be worth a line in the release notes, since some cookies that used to be modeled no longer will be.
pjfanning
added a commit
that referenced
this pull request
Nov 19, 2026
Motivation: Several recently merged PRs left review points unaddressed: docs that were asked to be dropped, comments and tests that were suggested, and small API and internal tidy-ups. Modification: - Add a Scala FilenameEncoding alias and values to Multipart.FormData and use them in the Scala toEntity signature and tests (#1494). - Render the form-data Content-Disposition header directly instead of rendering it twice and slicing off the prefix (#1494). - Drop the docs paragraph about unpaired URI surrogates (#1426) and the cookie -0000 sentence in request-level.md (#1493). - Fix the javadsl Multipart.FormData doc the same way #1483 fixed the scaladsl one. - Comment the cookie date rule copies so they stay in sync (#1458). - Test custom methods starting with Q next to the QUERY fast path (#1477). - Use one root package import and a dilated timeout in HeaderCompressionSpec (#1438). - Pass isTrailer to HttpMessageRendering.renderHeaders explicitly (#1463). - Remove the unused forwarding overloads in Handshake.Client and EnabledPingState (#1436, #1462). - Move the media type model checks from the routing spec to a new http-core MediaTypesSpec (#1437, #1454). - Hash the WebSocket key without String.valueOf (#1439). Result: The review points are addressed. The only public API change is the added Scala FilenameEncoding alias. Tests: - http-core/testOnly MultipartSpec MultipartsSpec MediaTypesSpec RequestParserCRLFSpec RequestParserLFSpec HeaderCompressionSpec WebSocketClientSpec HeaderSpec HttpHeaderSpec: 314 passed - http2-tests/testOnly HttpMessageRenderingSpec Http2PingSchedulingSpec: 38 passed - http-tests/testOnly FileAndResourceDirectivesSpec: 63 passed - http-core/mimaReportBinaryIssues: passed References: Refs #1426, #1436, #1437, #1438, #1439, #1454, #1458, #1462, #1463, #1477, #1483, #1493, #1494
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
RFC 6265 section 5.1.1 permits one or two digits in each cookie-date time component.
HttpHeader.parsecurrently modelsSet-Cookie: sid=value; Expires=Sun, 06 Nov 1994 8:9:7 GMTwithout errors but gives itDateTime.MinValue, whereas the equivalent08:09:07is parsed correctly.Modification
Use cookie-specific expiry-date alternatives for the existing IMF/rfc850-shaped and asctime-shaped forms. Accept one or two time digits while retaining the existing date construction and weekday validation. Keep the original HTTP-date branch first; shared HTTP-date and standalone Expires parsing and canonical rendering are unchanged.
This is a bounded receiving-interoperability fix, not a complete implementation of RFC 6265's cookie-date token algorithm or browser cookie storage. It does not change token order or weekday policy. Newly recognized shapes with invalid numeric/weekday fields now reach the existing validation instead of the unrecognized-date fallback; canonical invalid inputs retain their existing behavior.
Release note
Cookie
Expiresdates now accept one or two digits per time component, as RFC 6265 allows, e.g.Expires=Sun, 06 Nov 1994 8:9:7 GMT. Before, such a date was silently replaced withDateTime.MinValue. ASet-Cookieheader whose single-digit date is invalid (e.g.24:0:0) now fails date validation and becomes aRawHeaderwith errors, as the two-digit form already did, instead of being modeled withDateTime.MinValue.DateandExpiresheader parsing is unchanged.Tests
Some(1800-01-01T00:00:00)instead of the expected timestamp.HttpHeaderSpec,HeaderSpec, and JavaHttpCookieSpec: 118 passed. ConcreteHttpHeaderParserCRLFSpecandHttpHeaderParserLFSpec: 66 passed (184 distinct tests total, including 11 new tests).The Netty DateFormatter single-digit tests were an audit clue. This is an independent implementation against Pekko's existing parser, not a port of Netty's broader date parser.
Reference: https://www.rfc-editor.org/rfc/rfc6265.html#section-5.1.1