https://github.com/python/cpython/commit/c80e446e6b91fb64e1cbfed8986869accd1fafb6
commit: c80e446e6b91fb64e1cbfed8986869accd1fafb6
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-04-30T22:19:46+03:00
summary:
gh-149028: Revert gh-92936 changes (GH-149182)
* Revert "gh-92936: update `http.cookies` docs post GH-113663 (#137566)"
This reverts commit d86c2257a69a8d6c650c0db470499463131a569f.
* Revert "gh-92936: allow double quote in cookie values (#113663)"
This reverts commit d7dbde895884d58e3da7ed4107fd33171afad7cb.
files:
M Doc/library/http.cookies.rst
M Doc/whatsnew/3.15.rst
M Lib/http/cookies.py
M Lib/test/test_http_cookies.py
diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst
index b3fcd21c7e2244..1122b30d29def0 100644
--- a/Doc/library/http.cookies.rst
+++ b/Doc/library/http.cookies.rst
@@ -25,10 +25,8 @@ The character set, :data:`string.ascii_letters`,
:data:`string.digits` and
in a cookie name (as :attr:`~Morsel.key`).
.. versionchanged:: 3.3
- Allowed '``:``' as a valid cookie name character.
+ Allowed ':' as a valid cookie name character.
-.. versionchanged:: 3.15
- Allowed '``"``' as a valid cookie value character.
.. note::
@@ -313,10 +311,3 @@ The following example demonstrates how to use the
:mod:`!http.cookies` module.
>>> print(C)
Set-Cookie: number=7
Set-Cookie: string=seven
- >>> import json
- >>> C = cookies.SimpleCookie()
- >>> C.load(f'cookies=7; mixins="{json.dumps({"chips": "dark chocolate"})}";
state=gooey')
- >>> print(C)
- Set-Cookie: cookies=7
- Set-Cookie: mixins="{"chips": "dark chocolate"}"
- Set-Cookie: state=gooey
diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst
index 90d24bf96afeb4..a687ee5115be05 100644
--- a/Doc/whatsnew/3.15.rst
+++ b/Doc/whatsnew/3.15.rst
@@ -947,13 +947,6 @@ http.client
(Contributed by Alexander Enrique Urieles Nieto in :gh:`131724`.)
-http.cookies
-------------
-
-* Allow '``"``' double quotes in cookie values.
- (Contributed by Nick Burns and Senthil Kumaran in :gh:`92936`.)
-
-
http.server
-----------
diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py
index 660fec4f1be865..5c5b14788dc2f0 100644
--- a/Lib/http/cookies.py
+++ b/Lib/http/cookies.py
@@ -462,7 +462,7 @@ def OutputString(self, attrs=None):
( # 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
diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py
index cfcbc17bd6df80..4884b07c95b9c5 100644
--- a/Lib/test/test_http_cookies.py
+++ b/Lib/test/test_http_cookies.py
@@ -48,29 +48,6 @@ def test_basic(self):
'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"',
- ))
}
]
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]