mirror of
https://github.com/python/cpython.git
synced 2025-11-24 12:20:42 +00:00
gh-92936: allow double quote in cookie values (#113663)
Some checks are pending
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
Some checks are pending
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
* allow double quote in cookie values * Update Lib/test/test_http_cookies.py Co-authored-by: Senthil Kumaran <senthil@python.org>
This commit is contained in:
parent
34d7351ac7
commit
d7dbde8958
3 changed files with 26 additions and 1 deletions
|
|
@ -426,7 +426,7 @@ _CookiePattern = re.compile(r"""
|
|||
( # Optional group: there may not be a value.
|
||||
\s*=\s* # Equal Sign
|
||||
(?P<val> # Start of group 'val'
|
||||
"(?:[^\\"]|\\.)*" # Any double-quoted string
|
||||
"(?:\\"|.)*?" # Any double-quoted string
|
||||
| # or
|
||||
# Special case for "expires" attr
|
||||
(\w{3,6}day|\w{3}),\s # Day of the week or abbreviated day
|
||||
|
|
|
|||
|
|
@ -48,6 +48,29 @@ class CookieTests(unittest.TestCase):
|
|||
'Set-Cookie: d=r',
|
||||
'Set-Cookie: f=h'
|
||||
))
|
||||
},
|
||||
|
||||
# gh-92936: allow double quote in cookie values
|
||||
{
|
||||
'data': 'cookie="{"key": "value"}"',
|
||||
'dict': {'cookie': '{"key": "value"}'},
|
||||
'repr': "<SimpleCookie: cookie='{\"key\": \"value\"}'>",
|
||||
'output': 'Set-Cookie: cookie="{"key": "value"}"',
|
||||
},
|
||||
{
|
||||
'data': 'key="some value; surrounded by quotes"',
|
||||
'dict': {'key': 'some value; surrounded by quotes'},
|
||||
'repr': "<SimpleCookie: key='some value; surrounded by quotes'>",
|
||||
'output': 'Set-Cookie: key="some value; surrounded by quotes"',
|
||||
},
|
||||
{
|
||||
'data': 'session="user123"; preferences="{"theme": "dark"}"',
|
||||
'dict': {'session': 'user123', 'preferences': '{"theme": "dark"}'},
|
||||
'repr': "<SimpleCookie: preferences='{\"theme\": \"dark\"}' session='user123'>",
|
||||
'output': '\n'.join((
|
||||
'Set-Cookie: preferences="{"theme": "dark"}"',
|
||||
'Set-Cookie: session="user123"',
|
||||
))
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
Update regex used by ``http.cookies.SimpleCookie`` to handle values containing
|
||||
double quotes.
|
||||
Loading…
Add table
Add a link
Reference in a new issue