]> granicus.if.org Git - python/commitdiff
Fix Issue2193 - Allow ":" character in Cookie NAME values
authorSenthil Kumaran <senthil@uthcode.com>
Sun, 22 Apr 2012 01:19:04 +0000 (09:19 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Sun, 22 Apr 2012 01:19:04 +0000 (09:19 +0800)
Lib/http/cookies.py
Lib/test/test_http_cookies.py
Misc/NEWS

index 93da62791df4f3389e731cef910323fae565e417..d73f79a665c8bd8414ff9e93ab10a91fbc7b61a9 100644 (file)
@@ -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',
index f9a98c4ae1427107f4872a3b29a5b0a24ecb3637..a56a42d8d41dba14241308226208188fb76a6b34 100644 (file)
@@ -34,6 +34,15 @@ class CookieTests(unittest.TestCase):
              'dict': {'keebler' : 'E=mc2'},
              'repr': "<SimpleCookie: keebler='E=mc2'>",
              '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': "<SimpleCookie: key:term='value:term'>",
+             'output': 'Set-Cookie: key:term=value:term'},
+
         ]
 
         for case in cases:
index 08a1dd3e4ba3abe10adb999d01262e02bcf86f5e..120b57fc27685d72a9da700322311205266d18ad 100644 (file)
--- 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.