Repository navigation
fix: ignore Expires attributes that parse as Invalid Date - #91
Merged
nfriedly merged 1 commit intoOct 16, 2026
Merged
Conversation
Owner
|
Thanks for this! I have a branch where I have a custom date parser, but I think it will compliment this. Do you have any real-world examples of where this went wrong, or is it just a theoretical fix? |
Author
|
Thanks! I found this proactively while checking invalid Expires handling; I don't have a confirmed production incident. The regression is synthetic: an invalid duplicate Expires currently overwrites an earlier valid date with Invalid Date. This is a standards-conformance fix: ignore the invalid attribute and retain the valid expiry. |
Owner
|
Ok, this will be published shortly in v3.1.4 |
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.
An unparseable Expires attribute currently adds an Invalid Date to the returned cookie. A malformed duplicate also overwrites an earlier valid expiry, for example Expires=Wed, 21 Oct 2026 07:28:00 GMT; Expires=not-a-date. RFC 6265 section 5.2.1 requires ignoring an Expires attribute whose date cannot be parsed.
Only assign expires when the parsed Date has a valid timestamp. Tests cover empty and unparseable values, preserving an earlier valid expiry, retaining other attributes, and using the last valid expiry including the Unix epoch.
Validation on Node 20.19.5: two new regression tests fail on the original source. With the fix, npm test passes: CommonJS build, complete ESLint check, 67 Mocha tests, and tsd type checks. git diff --check also passes.
This retains native Date parsing; it does not implement the full cookie-date grammar or resolve the engine-specific valid-date issue in #35.