Repository navigation
Conversation
`parseSetCookie` read Expires with `new Date(str)`. For anything but ISO strings that parse is engine-defined, a date without a zone is read in the local time zone, and strings such as "1" or "2015" became dates. Use the algorithm from RFC 6265 sec 5.1.1 instead: always UTC, two-digit years, and the attribute is ignored unless the day, month, year and time are all present and valid.
Author
|
Friendly ping on this fix for #295. No conflicts, and I can trim it if you would rather keep a smaller parser. |
This branch has not been deployed
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.
Fixes #295.
parseSetCookieparsedExpireswithnew Date(val). That is engine-defined for non-ISO strings, reads a date without a zone in the local time zone, and turns strings like1or2015into dates.This replaces it with the cookie-date algorithm from RFC 6265 section 5.1.1:
hh:mm:sstime, 1-2 digit day, month name prefix, and 2-4 digit year30 Feb)Date.UTC, so the result is the same in every time zone and engineBehavior change: ISO strings like
2015-10-21T07:28:00Zare no longer accepted asExpires, same as in browsers. The usualWed, 21 Oct 2015 07:28:00 GMTand21-Oct-15forms parse as before (the top-sites snapshots are unchanged).Size: this adds about 280 bytes (brotli), so I raised the
size-limitfrom 1.4 KB to 1.6 KB (now 1.54 KB). Happy to trim it further if you have a target in mind.Tests: new cases for the RFC 1123, RFC 850, asctime and two-digit-year forms, values that must be ignored, and a zone-less date read with
TZ=America/New_York. 11 of them fail onmaster.npm testpasses (63771 tests, size check included).