]> granicus.if.org Git - python/commitdiff
merge 3.2 (#22931)
authorBenjamin Peterson <benjamin@python.org>
Sat, 23 May 2015 15:38:48 +0000 (10:38 -0500)
committerBenjamin Peterson <benjamin@python.org>
Sat, 23 May 2015 15:38:48 +0000 (10:38 -0500)
1  2 
Lib/http/cookies.py
Lib/test/test_http_cookies.py
Misc/NEWS

index 556d101fb0e870e3312d453f6a94ce8dbac01ede,50aabd60d2a6bb91970309890eb6c4b0906efae0..00082a6740ff7a5e1022eaee22a0863bb3d12d70
@@@ -433,20 -435,17 +434,20 @@@ _CookiePattern = re.compile(r""
      (?x)                           # This is a verbose pattern
      \s*                            # Optional whitespace at start of cookie
      (?P<key>                       # Start of group 'key'
-     """ + _LegalCharsPatt + r"""+?   # Any word of at least one letter
+     [""" + _LegalKeyChars + r"""]+?   # Any word of at least one letter
      )                              # End of group 'key'
 -    \s*=\s*                        # Equal Sign
 -    (?P<val>                       # Start of group 'val'
 -    "(?:[^\\"]|\\.)*"                # Any doublequoted string
 -    |                                # or
 +    (                              # Optional group: there may not be a value.
 +    \s*=\s*                          # Equal Sign
 +    (?P<val>                         # Start of group 'val'
 +    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
 +    |                                  # or
      \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
 -    |                                # or
 -    [""" + _LegalValueChars + r"""]*    # Any word or empty string
 -    )                              # End of group 'val'
 -    \s*;?                          # Probably ending in a semi-colon
 +    |                                  # or
-     """ + _LegalCharsPatt + r"""*      # Any word or empty string
++    [""" + _LegalValueChars + r"""]*      # Any word or empty string
 +    )                                # End of group 'val'
 +    )?                             # End of optional value group
 +    \s*                            # Any number of spaces.
 +    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
      """, re.ASCII)                 # May be removed if safe.
  
  
index 76e5e9c4daddb828a468cf96f367f3e526cd84d1,a0edcbfc901c0fc124f953b13ba50046ef19cbd5..8d7c220c5b623624a8c203308c846e9936d8225c
@@@ -35,14 -35,19 +35,27 @@@ class CookieTests(unittest.TestCase)
               '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'},
 +
+             # issue22931 - Adding '[' and ']' as valid characters in cookie
+             # values as defined in RFC 6265
+             {
+                 'data': 'a=b; c=[; d=r; f=h',
+                 'dict': {'a':'b', 'c':'[', 'd':'r', 'f':'h'},
+                 'repr': "<SimpleCookie: a='b' c='[' d='r' f='h'>",
+                 'output': '\n'.join((
+                     'Set-Cookie: a=b',
+                     'Set-Cookie: c=[',
+                     'Set-Cookie: d=r',
+                     'Set-Cookie: f=h'
+                 ))
+             }
          ]
  
          for case in cases:
diff --cc Misc/NEWS
index 827d761bf9f6838f561f55b165df5d2544fc2e38,b33c5a4169a4f1e3c6e419a0dd172078ac437b91..0f969207d43d051f5065f048d616e5bd9b22e226
+++ b/Misc/NEWS
@@@ -22,32 -19,10 +22,34 @@@ Core and Builtin
  Library
  -------
  
+ - Issue #22931: Allow '[' and ']' in cookie values.
 +- Issue #24094: Fix possible crash in json.encode with poorly behaved dict
 +  subclasses.
 +
 +- Issue #23367: Fix possible overflows in the unicodedata module.
 +
 +- Issue #23361: Fix possible overflow in Windows subprocess creation code.
 +
 +- Issue #23363: Fix possible overflow in itertools.permutations.
 +
 +- Issue #23364: Fix possible overflow in itertools.product.
 +
 +- Issue #23369: Fixed possible integer overflow in
 +  _json.encode_basestring_ascii.
 +
 +- Issue #23366: Fixed possible integer overflow in itertools.combinations.
 +
 +- Issue #23365: Fixed possible integer overflow in
 +  itertools.combinations_with_replacement.
  
 -What's New in Python 3.2.6?
 +C API
 +-----
 +
 +- Issue #23998: PyImport_ReInitLock() now checks for lock allocation error
 +
 +
 +What's New in Python 3.3.6?
  ===========================
  
  *Release date: 11-Oct-2014*