]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-149028: Revert gh-92936 changes (GH-149182)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 30 Apr 2026 19:19:46 +0000 (22:19 +0300)
committerGitHub <noreply@github.com>
Thu, 30 Apr 2026 19:19:46 +0000 (22:19 +0300)
* 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.

Doc/library/http.cookies.rst
Doc/whatsnew/3.15.rst
Lib/http/cookies.py
Lib/test/test_http_cookies.py

index b3fcd21c7e224487dd8b65d72e5620b4e2d57cc0..1122b30d29def0f3abbcaab71fd1e07f2975da64 100644 (file)
@@ -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
index 90d24bf96afeb47a00bdb435317357a79f3849d2..a687ee5115be0590dd387527ea909dae23a422b9 100644 (file)
@@ -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
 -----------
 
index 660fec4f1be8654e7fe17e1029167149607330b5..5c5b14788dc2f09bf20a779ddbab8391da1af4dd 100644 (file)
@@ -462,7 +462,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
index cfcbc17bd6df80d8405e47bfa6788cfc315b052c..4884b07c95b9c50a29831316842be14a48e325f9 100644 (file)
@@ -48,29 +48,6 @@ 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"',
-                ))
             }
         ]