(original) (raw)

changeset: 100317:91eb7ae951a1 parent: 100315:47fa003aa9f1 parent: 100316:758cb13aaa2c user: Jason R. Coombs jaraco@jaraco.com date: Wed Feb 24 08:50:59 2016 -0500 files: Misc/NEWS description: Issue #26302: merge from 3.5 diff -r 47fa003aa9f1 -r 91eb7ae951a1 Lib/http/cookies.py --- a/Lib/http/cookies.py Wed Feb 24 13:04:33 2016 +0200 +++ b/Lib/http/cookies.py Wed Feb 24 08:50:59 2016 -0500 @@ -174,7 +174,7 @@ ord('\\'): '\\\\', }) -_is_legal_key = re.compile('[%s]+' % _LegalChars).fullmatch +_is_legal_key = re.compile('[%s]+' % re.escape(_LegalChars)).fullmatch def _quote(str): r"""Quote a string for use in a cookie header. diff -r 47fa003aa9f1 -r 91eb7ae951a1 Lib/test/test_http_cookies.py --- a/Lib/test/test_http_cookies.py Wed Feb 24 13:04:33 2016 +0200 +++ b/Lib/test/test_http_cookies.py Wed Feb 24 08:50:59 2016 -0500 @@ -210,6 +210,12 @@ C1 = pickle.loads(pickle.dumps(C, protocol=proto)) self.assertEqual(C1.output(), expected_output) + def test_illegal_chars(self): + rawdata = "a=b; c,d=e" + C = cookies.SimpleCookie() + with self.assertRaises(cookies.CookieError): + C.load(rawdata) + class MorselTests(unittest.TestCase): """Tests for the Morsel object.""" diff -r 47fa003aa9f1 -r 91eb7ae951a1 Misc/NEWS --- a/Misc/NEWS Wed Feb 24 13:04:33 2016 +0200 +++ b/Misc/NEWS Wed Feb 24 08:50:59 2016 -0500 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #26302: Correct behavior to reject comma as a legal character for + cookie names. + - Issue #26136: Upgrade the warning when a generator raises StopIteration from PendingDeprecationWarning to DeprecationWarning. Patch by Anish Shah. /jaraco@jaraco.com