[PR #13278/d5d068cb backport][3.15] parse cookie expires date as ascii-only - #13317
Conversation
(cherry picked from commit d5d068c)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.15 #13317 +/- ##
=======================================
Coverage 98.27% 98.27%
=======================================
Files 136 136
Lines 49382 49417 +35
Branches 2665 2666 +1
=======================================
+ Hits 48528 48564 +36
Misses 674 674
+ Partials 180 179 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Hooray! CodSpeed harness just leveled up!The base and head of this comparison were measured with different runner settings, so their benchmark values are not directly comparable. What changed between base and head:
Re-run the base with the same settings to get a valid performance comparison. Comparing Footnotes |
This is a backport of PR #13278 as merged into master (d5d068c).
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