Repository navigation
fix: accept a negative Set-Cookie Max-Age attribute #5571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -186,17 +186,19 @@ function parseUnparsedAttributes (unparsedAttributes, cookieAttributeList = {}) | |||||
| // If the attribute-name case-insensitively matches the string "Max- | ||||||
| // Age", the user agent MUST process the cookie-av as follows. | ||||||
|
|
||||||
| // 1. If the first character of the attribute-value is not a DIGIT or a | ||||||
| // "-" character, ignore the cookie-av. | ||||||
| // 1. If the first character of the attribute-value is neither a DIGIT, | ||||||
| // nor a "-" character followed by a DIGIT, ignore the cookie-av. | ||||||
| const charCode = attributeValue.charCodeAt(0) | ||||||
| const startsWithDigit = charCode >= 48 && charCode <= 57 | ||||||
| const startsWithSignedDigit = attributeValue[0] === '-' && attributeValue.length > 1 | ||||||
|
|
||||||
| if ((charCode < 48 || charCode > 57) && attributeValue[0] !== '-') { | ||||||
| if (!startsWithDigit && !startsWithSignedDigit) { | ||||||
| return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList) | ||||||
| } | ||||||
|
|
||||||
| // 2. If the remainder of attribute-value contains a non-DIGIT | ||||||
| // character, ignore the cookie-av. | ||||||
| if (!/^\d+$/.test(attributeValue)) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make the following changes to ensure closer adherence to the specifications.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, that reads much closer to the spec. I took the remainder check as suggested and also tightened step 1 to the current 6265bis wording (a "-" followed by a DIGIT). Without that, slice(1) lets a bare |
||||||
| if (/[^\d]/.test(attributeValue.slice(1))) { | ||||||
| return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList) | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please revert this change? This comment block is intended to preserve the exact wording from the specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted, the comment block is back to the original spec wording. The code still does the sign-followed-by-digit check but the comment stays verbatim.