From bb7964d1109f32f00f9a532d22625ace3b16ba3f Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Fri, 8 Aug 2025 20:26:34 +0000 Subject: [PATCH 1/9] add versionchanged and example with quotes in cookie value --- Doc/library/http.cookies.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index 46efc45c5e7d96..a0b96c3019d373 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -30,6 +30,8 @@ in a cookie name (as :attr:`~Morsel.key`). .. versionchanged:: 3.3 Allowed ':' as a valid cookie name character. +.. versionchanged:: 3.15 + Allowed '"' as a valid cookie value character. .. note:: @@ -314,3 +316,9 @@ The following example demonstrates how to use the :mod:`http.cookies` module. >>> print(C) Set-Cookie: number=7 Set-Cookie: string=seven + >>> C = cookies.SimpleCookie() + >>> C.load('cookies=7; mixins="{"chips": "dark chocolate"}"; state="gooey"') + >>> print(C) + Set-Cookie: cookies=7 + Set-Cookie: mixins="{"chips": "dark chocolate"}" + Set-Cookie: state="gooey" From 75803bcb1ca9f05d655b2572f7da8ecd04b484c0 Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Fri, 8 Aug 2025 20:35:08 +0000 Subject: [PATCH 2/9] update whatsnew with http.cookies change --- Doc/whatsnew/3.15.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 9f01b52f1aff3b..a04f34ce0de6e9 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -263,6 +263,14 @@ http.client (Contributed by Alexander Enrique Urieles Nieto in :gh:`131724`.) +http.cookies +------------ + +* Allow double quotes in cookie values with a more linient regex for + doublequoted strings. + (Contributed by Nick Burns and Senthil Kumaran in :gh:`137566`.) + + math ---- From b92bdf7307754f7479b55ae6753be774a7123d70 Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Fri, 8 Aug 2025 14:27:12 -0700 Subject: [PATCH 3/9] Update Doc/library/http.cookies.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Doc/library/http.cookies.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index a0b96c3019d373..5c87c00bd93c6b 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -30,7 +30,7 @@ in a cookie name (as :attr:`~Morsel.key`). .. versionchanged:: 3.3 Allowed ':' as a valid cookie name character. -.. versionchanged:: 3.15 +.. versionchanged:: next Allowed '"' as a valid cookie value character. .. note:: From 7ec1391475b18b7955124b45534f1e37f7331a26 Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Fri, 8 Aug 2025 14:27:57 -0700 Subject: [PATCH 4/9] Update Doc/whatsnew/3.15.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Doc/whatsnew/3.15.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index a04f34ce0de6e9..51fe5408a46cf3 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -268,7 +268,7 @@ http.cookies * Allow double quotes in cookie values with a more linient regex for doublequoted strings. - (Contributed by Nick Burns and Senthil Kumaran in :gh:`137566`.) + (Contributed by Nick Burns and Senthil Kumaran in :gh:`92936`.) math From 78d0d1bcd6894f43fb9bdf2b1acbf1bdc3116000 Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Fri, 8 Aug 2025 21:29:07 +0000 Subject: [PATCH 5/9] spelling, quote --- Doc/whatsnew/3.15.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 51fe5408a46cf3..df3a9f88501090 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -266,8 +266,8 @@ http.client http.cookies ------------ -* Allow double quotes in cookie values with a more linient regex for - doublequoted strings. +* Allow ``"`` double quotes in cookie values with a more linient regex for + double-quoted strings. (Contributed by Nick Burns and Senthil Kumaran in :gh:`92936`.) From ce2eee0f901e5f6171b6535a1b11ced14d125ecb Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Tue, 12 Aug 2025 16:47:53 +0000 Subject: [PATCH 6/9] demonstrate json --- Doc/library/http.cookies.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index 5c87c00bd93c6b..a5256201b72d04 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -316,8 +316,9 @@ 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('cookies=7; mixins="{"chips": "dark chocolate"}"; state="gooey"') + >>> 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"}" From d71b806f60edf886b11c08f7a71edbc4ce8ec0dc Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Wed, 13 Aug 2025 09:07:24 -0700 Subject: [PATCH 7/9] Update Doc/library/http.cookies.rst Co-authored-by: Senthil Kumaran --- Doc/library/http.cookies.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index a5256201b72d04..99786fa06ef62b 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -322,4 +322,4 @@ The following example demonstrates how to use the :mod:`http.cookies` module. >>> print(C) Set-Cookie: cookies=7 Set-Cookie: mixins="{"chips": "dark chocolate"}" - Set-Cookie: state="gooey" + Set-Cookie: state=gooey From ccc42e5660f229de20a59fb5f760710dc8e37769 Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Thu, 14 Aug 2025 15:26:00 -0700 Subject: [PATCH 8/9] Apply suggestions from code review Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- Doc/library/http.cookies.rst | 4 ++-- Doc/whatsnew/3.15.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst index 99786fa06ef62b..9e7648ef6d8345 100644 --- a/Doc/library/http.cookies.rst +++ b/Doc/library/http.cookies.rst @@ -28,10 +28,10 @@ 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:: next - Allowed '"' as a valid cookie value character. + Allowed '``"``' as a valid cookie value character. .. note:: diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index df3a9f88501090..cde8ff2df8fcd2 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -266,7 +266,7 @@ http.client http.cookies ------------ -* Allow ``"`` double quotes in cookie values with a more linient regex for +* Allow '``"``' double quotes in cookie values with a more lenient regex for double-quoted strings. (Contributed by Nick Burns and Senthil Kumaran in :gh:`92936`.) From 3b6a9176343d9b63ea2dd97ceff5500299e5b71f Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Fri, 15 Aug 2025 16:32:08 +0000 Subject: [PATCH 9/9] shorter description --- Doc/whatsnew/3.15.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index cde8ff2df8fcd2..4cbc5fceb33207 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -266,8 +266,7 @@ http.client http.cookies ------------ -* Allow '``"``' double quotes in cookie values with a more lenient regex for - double-quoted strings. +* Allow '``"``' double quotes in cookie values. (Contributed by Nick Burns and Senthil Kumaran in :gh:`92936`.)