diff options
author | Georg Brandl <georg@python.org> | 2010-08-01 09:06:34 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-08-01 09:06:34 (GMT) |
commit | b16e38b8254e0e1bbffaf16971351a5eb31a5846 (patch) | |
tree | fedeaf5564ab393f1db0c288378f5fb13217432e /Lib | |
parent | bda4672b019dfca67c0d97ea7452d33decbd974c (diff) | |
download | cpython-b16e38b8254e0e1bbffaf16971351a5eb31a5846.zip cpython-b16e38b8254e0e1bbffaf16971351a5eb31a5846.tar.gz cpython-b16e38b8254e0e1bbffaf16971351a5eb31a5846.tar.bz2 |
#8826: the "expires" attribute value is a date string with spaces, but apparently not all user-agents put it in quotes. Handle that as a special case.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/http/cookies.py | 2 | ||||
-rw-r--r-- | Lib/test/test_http_cookies.py | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index c36c494..9e51b67 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -434,6 +434,8 @@ _CookiePattern = re.compile(r""" (?P<val> # Start of group 'val' "(?:[^\\"]|\\.)*" # Any doublequoted string | # or + \w{3},\s[\w\d-]{9,11}\s[\d:]{8}\sGMT # Special case for "expires" attr + | # or """ + _LegalCharsPatt + r"""* # Any word or empty string ) # End of group 'val' \s*;? # Probably ending in a semi-colon diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py index 43ca9f5..b008e0f 100644 --- a/Lib/test/test_http_cookies.py +++ b/Lib/test/test_http_cookies.py @@ -76,6 +76,16 @@ class CookieTests(unittest.TestCase): # can't test exact output, it always depends on current date/time self.assertTrue(C.output().endswith('GMT')) + # loading 'expires' + C = cookies.SimpleCookie() + C.load('Customer="W"; expires=Wed, 01-Jan-2010 00:00:00 GMT') + self.assertEqual(C['Customer']['expires'], + 'Wed, 01-Jan-2010 00:00:00 GMT') + C = cookies.SimpleCookie() + C.load('Customer="W"; expires=Wed, 01-Jan-98 00:00:00 GMT') + self.assertEqual(C['Customer']['expires'], + 'Wed, 01-Jan-98 00:00:00 GMT') + # 'max-age' C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"') C['Customer']['max-age'] = 10 |