diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-05-23 15:36:48 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-05-23 15:36:48 (GMT) |
commit | 9bd476ea57e1f77c5d117577d721bff806137a09 (patch) | |
tree | d52aa4b0cfd0bd7e6245ce676bca25d791fb4dc8 /Lib/http | |
parent | 0823ffb2fb16aa29cefd4c1b91edd82d9814e46a (diff) | |
download | cpython-9bd476ea57e1f77c5d117577d721bff806137a09.zip cpython-9bd476ea57e1f77c5d117577d721bff806137a09.tar.gz cpython-9bd476ea57e1f77c5d117577d721bff806137a09.tar.bz2 |
allow square brackets in cookie values (closes #22931)
Diffstat (limited to 'Lib/http')
-rw-r--r-- | Lib/http/cookies.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index 28c1161..50aabd6 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -429,12 +429,13 @@ class Morsel(dict): # result, the parsing rules here are less strict. # -_LegalCharsPatt = r"[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]" +_LegalKeyChars = r"\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=" +_LegalValueChars = _LegalKeyChars + '\[\]' _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' @@ -442,7 +443,7 @@ _CookiePattern = re.compile(r""" | # or \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT # Special case for "expires" attr | # or - """ + _LegalCharsPatt + r"""* # Any word or empty string + [""" + _LegalValueChars + r"""]* # Any word or empty string ) # End of group 'val' \s*;? # Probably ending in a semi-colon """, re.ASCII) # May be removed if safe. |