From 3a441c1bedf1091ed4a177e5d7f0a12ef9f9fa65 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 22 Apr 2012 09:19:04 +0800 Subject: [PATCH] Fix Issue2193 - Allow ":" character in Cookie NAME values --- Lib/http/cookies.py | 2 +- Lib/test/test_http_cookies.py | 9 +++++++++ Misc/NEWS | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index 93da62791df..d73f79a665c 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -159,7 +159,7 @@ class CookieError(Exception): # _LegalChars is the list of chars which don't require "'s # _Translator hash-table for fast quoting # -_LegalChars = string.ascii_letters + string.digits + "!#$%&'*+-.^_`|~" +_LegalChars = string.ascii_letters + string.digits + "!#$%&'*+-.^_`|~:" _Translator = { '\000' : '\\000', '\001' : '\\001', '\002' : '\\002', '\003' : '\\003', '\004' : '\\004', '\005' : '\\005', diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py index f9a98c4ae14..a56a42d8d41 100644 --- a/Lib/test/test_http_cookies.py +++ b/Lib/test/test_http_cookies.py @@ -34,6 +34,15 @@ class CookieTests(unittest.TestCase): 'dict': {'keebler' : 'E=mc2'}, 'repr': "", 'output': 'Set-Cookie: keebler=E=mc2'}, + + # Cookies with ':' character in their name. Though not mentioned in + # RFC, servers / browsers allow it. + + {'data': 'key:term=value:term', + 'dict': {'key:term' : 'value:term'}, + 'repr': "", + 'output': 'Set-Cookie: key:term=value:term'}, + ] for case in cases: diff --git a/Misc/NEWS b/Misc/NEWS index 08a1dd3e4ba..120b57fc276 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -61,6 +61,8 @@ Core and Builtins Library ------- +- Issue #2193: Allow ":" character in Cookie NAME values. + - Issue #14629: tokenizer.detect_encoding will specify the filename in the SyntaxError exception if found at readline.__self__.name.