Repository navigation
Send cookies back as the server sent them - #14508
tugayabdulla wants to merge 2 commits into
Conversation
Insufficient dataNot enough activity yet to make a reliable assessment. This is an automated analysis by AgentScan |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #14508 +/- ##
========================================
Coverage 99.12% 99.12%
========================================
Files 135 135
Lines 54123 54257 +134
Branches 2778 2785 +7
========================================
+ Hits 53648 53782 +134
Misses 359 359
Partials 116 116
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 performance1 warning
Comparing Footnotes
|
[Medium impact] The PR appears safe to merge; both previous findings are fixed, and no new actionable issues were found. Reviews (2) · Last reviewed commit: "Link the changelog to the PR and scope t..." · Reviewed by Greptile |
atishay-kasliwal
left a comment
There was a problem hiding this comment.
Round trip through an aiohttp server and ClientSession: cookies set as t=YWJjZA==, c=a,b, s=a b, j={"k":1} and x=café now come back exactly as sent. Master quoted or octal-escaped them (t="YWJjZA==", c="a\054b", x="caf\351"). Values set from strings with update_cookies are still quoted (a="val/one").
What do these changes do?
With the default
quote_cookie=True, the cookie jar re-quoted cookie values received from a server when they contain characters such as=,/or a space, soSet-Cookie: token=YWJjZA==was sent back asCookie: token="YWJjZA==". Browsers send the value back byte for byte, and some servers reject the quoted form.Following bdraco's suggestion in the issue, with the default the jar now always sends the stored coded value. For cookies from a server that is the value exactly as received; for values set from plain strings it is the form they were already quoted to when stored, so those are unchanged.
Are there changes in behavior for the user?
Yes: cookies received from a server are no longer quoted when sent back.
quote_cookie=Falsebehaves as before. Since this changes a default, I targeted master; if you want a deprecation step on 3.x first, as discussed in the issue, I can add one.Is it a substantial burden for the maintainers to support this?
No. It removes a branch from
_build_morseland the module-levelSimpleCookiethat was used for re-encoding.Related issue number
Fixes #11200
Checklist
CONTRIBUTORS.txtCHANGES/folder(
CHANGES/11200.bugfix.rst, withCHANGES/14508.bugfix.rstlinking to it)Test results
On master,
test_set_cookies_sent_back_as_receivedand the two "received cookie" cases oftest_quotes_correctly_based_on_inputfail; they pass with this change.test_quotes_cookie_values_set_from_stringspasses on both and checks that values set from strings are still quoted. mypy reports the same errors as on master, none in the changed files.Drafted with Claude Code (Claude Opus 5.5); reviewed by @tugayabdulla.