Skip to content

Ignore parsed Expires dates outside cookie year bounds - #292

Closed
arin30 wants to merge 1 commit into
jshttp:masterfrom
arin30:fix/parsed-expires-year-bounds
Closed

arin30 wants to merge 1 commit into
jshttp:masterfrom
arin30:fix/parsed-expires-year-bounds

Conversation

@arin30

@arin30 arin30 commented Nov 5, 2026

Copy link
Copy Markdown

parseSetCookie() accepts Expires dates with UTC years 1500, 1600, and 10000 because JavaScript considers them valid dates. stringifySetCookie() rejects those same years after #290. A later invalid Expires attribute can also overwrite an earlier valid one.

Check the parsed UTC year against the existing serializer's 1601–9999 bounds before assigning expires. Invalid dates still get ignored, and parsing continues with the remaining attributes. This is a small date-validation fix; it does not replace the existing Date-based parser with a full cookie-date tokenizer.

Tests cover three rejected years, preservation of an earlier valid expiration, and the valid 1601/9999 boundaries. On unchanged master, six new cases fail and the two boundary controls pass.

Validation on Node 24.22.1: npm test passes — TypeScript build, Prettier, typecheck, 63,760 Vitest cases, and size-limit (1.27 kB under the 1.4 kB limit). git diff --check passes.

Reference: RFC 6265 sections 4.1.1 and 5.1.1: https://www.rfc-editor.org/rfc/rfc6265#section-5.1.1

@blakeembrey

Copy link
Copy Markdown
Member

Not at this time. The parser is intentionally more lenient than the serializer.

@blakeembrey blakeembrey closed this Nov 5, 2026
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