| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
parseSetCookie assigned an Invalid Date to cookieAttributeList.expires when the Expires attribute failed to parse, instead of ignoring the attribute. RFC 6265bis 5.4.1 step 2 says to ignore the cookie-av when the date does not parse, which the adjacent code comment already stated. Only set expires when the parsed date is valid.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #5488 +/- ##
=======================================
Coverage 93.45% 93.45%
=======================================
Files 110 110
Lines 37147 37148 +1
=======================================
+ Hits 34716 34718 +2
+ Misses 2431 2430 -1 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
parseSetCookie assigns an Invalid Date to the parsed cookie's expires when the Set-Cookie Expires attribute fails to parse, instead of ignoring the attribute.
RFC 6265bis section 5.4.1 step 2 says that if the attribute-value fails to parse as a cookie date, the user agent must ignore the cookie-av. The code comment at that spot already states this, but the assignment ran unconditionally, leaking an Invalid Date into the returned object.
Fix
Only set expires when the parsed date is valid.
// 2. If the attribute-value failed to parse as a cookie date, ignore // the cookie-av. - - cookieAttributeList.expires = expiryTime + if (!Number.isNaN(expiryTime.getTime())) { + cookieAttributeList.expires = expiryTime + }Valid Expires values are unchanged.
Test
Added a case to test/cookie/cookies.js for an unparseable Expires. It fails before the change (expires: Invalid Date present) and passes after (attribute omitted). Full cookie suite stays green.