parse cookie expires date as ascii-only - #13278
Conversation
ad13734 to
1380b2a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13278 +/- ##
=======================================
Coverage 98.98% 98.98%
=======================================
Files 132 132
Lines 49023 49058 +35
Branches 2551 2552 +1
=======================================
+ Hits 48526 48561 +35
Misses 373 373
Partials 124 124
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Merging this PR will not alter performance
Comparing Footnotes
|
Co-authored-by: Sam Bull <aa6bs0@sambull.org>
Backport to 3.15: 💚 backport PR created✅ Backport PR branch: Backported as #13317 🤖 @patchback |
What do these changes do?
cookie
Expiresvalues are parsed inCookieJar._parse_datewith regexes whose\dclasses were compiled withoutre.ASCII, so\dalso matches unicode decimal digits (Arabic-Indic, fullwidth and the like). response header values reach the jar decoded as utf-8, so a server can send anExpiresbuilt from non-ascii digits andint()converts them just fine, giving a valid expiry identical to the plain-ascii date.RFC 6265 5.1.1 defines cookie-date digits as ascii only, and browsers reject such a date and keep the cookie as a session cookie, so today aiohttp can be handed a longer-lived cookie than a compliant client would retain. compiling the date regexes with
re.ASCIIrestricts them to ascii digits, in line with the spec and with how the rest of the parser already treats digits.Are there changes in behavior for the user?
Expiresvalues that rely on non-ascii digits now fail to parse and clear the attribute, so the cookie becomes a session cookie, the same as any other unparseable date. plain-ascii dates are unchanged.Is it a substantial burden for the maintainers to support this?
no, it is a flag on the existing date regexes plus a regression test.
Related issue number
N/A
Checklist
CONTRIBUTORS.txt— already presentCHANGES/folder