]> granicus.if.org Git - python/commitdiff
#8826: the "expires" attribute value is a date string with spaces, but apparently...
authorGeorg Brandl <georg@python.org>
Sun, 1 Aug 2010 09:06:34 +0000 (09:06 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 1 Aug 2010 09:06:34 +0000 (09:06 +0000)
Lib/http/cookies.py
Lib/test/test_http_cookies.py
Misc/NEWS

index c36c49457994beb3c24c297482c0e9095f292a3c..9e51b6791ca16489bc1f9318806b47177290ec08 100644 (file)
@@ -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
index 43ca9f5d62bd3586215532265531964e86a71842..b008e0ff2a50dd0306129395fb3a731e4001b0e7 100644 (file)
@@ -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
index 52cbabd0d95d81725fdc35c0de979a86a6da904c..96ff051ababcf3a007f57405dd7379f44a235088 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -15,6 +15,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #8826: Properly load old-style "expires" attribute in http.cookies.
+
 - Issue #1690103: Fix initial namespace for code run with trace.main().
 
 - Issue #7395: Fix tracebacks in pstats interactive browser.