Skip to content

Commit 3a441c1

Browse files
committed
Fix Issue2193 - Allow ":" character in Cookie NAME values
1 parent b8c0206 commit 3a441c1

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Lib/http/cookies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class CookieError(Exception):
159159
# _LegalChars is the list of chars which don't require "'s
160160
# _Translator hash-table for fast quoting
161161
#
162-
_LegalChars = string.ascii_letters + string.digits + "!#$%&'*+-.^_`|~"
162+
_LegalChars = string.ascii_letters + string.digits + "!#$%&'*+-.^_`|~:"
163163
_Translator = {
164164
'\000' : '\\000', '\001' : '\\001', '\002' : '\\002',
165165
'\003' : '\\003', '\004' : '\\004', '\005' : '\\005',

Lib/test/test_http_cookies.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ def test_basic(self):
3434
'dict': {'keebler' : 'E=mc2'},
3535
'repr': "<SimpleCookie: keebler='E=mc2'>",
3636
'output': 'Set-Cookie: keebler=E=mc2'},
37+
38+
# Cookies with ':' character in their name. Though not mentioned in
39+
# RFC, servers / browsers allow it.
40+
41+
{'data': 'key:term=value:term',
42+
'dict': {'key:term' : 'value:term'},
43+
'repr': "<SimpleCookie: key:term='value:term'>",
44+
'output': 'Set-Cookie: key:term=value:term'},
45+
3746
]
3847

3948
for case in cases:

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Core and Builtins
6161
Library
6262
-------
6363

64+
- Issue #2193: Allow ":" character in Cookie NAME values.
65+
6466
- Issue #14629: tokenizer.detect_encoding will specify the filename in the
6567
SyntaxError exception if found at readline.__self__.name.
6668

0 commit comments

Comments
 (0)