diff options
| author | Benjamin Peterson <benjamin@python.org> | 2015-05-23 15:46:25 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2015-05-23 15:46:25 (GMT) |
| commit | ec7abfb58fdf8ab6d1af1aba4731bf149a7d485e (patch) | |
| tree | 4c64e6dade983392d0e8a68ec088560d36ab566d /Lib/Cookie.py | |
| parent | a71a4f4ed32e9f1c6b43c7ac660dcc58cb0ce9bc (diff) | |
| download | cpython-ec7abfb58fdf8ab6d1af1aba4731bf149a7d485e.zip cpython-ec7abfb58fdf8ab6d1af1aba4731bf149a7d485e.tar.gz cpython-ec7abfb58fdf8ab6d1af1aba4731bf149a7d485e.tar.bz2 | |
allow square brackets in cookie values (#22931)
Diffstat (limited to 'Lib/Cookie.py')
| -rw-r--r-- | Lib/Cookie.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/Cookie.py b/Lib/Cookie.py index 0b15531..b1704d9 100644 --- a/Lib/Cookie.py +++ b/Lib/Cookie.py @@ -528,12 +528,13 @@ class Morsel(dict): # result, the parsing rules here are less strict. # -_LegalCharsPatt = r"[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]" +_LegalKeyChars = r"\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=" +_LegalValueChars = _LegalKeyChars + r"\[\]" _CookiePattern = re.compile( r"(?x)" # This is a Verbose pattern r"\s*" # Optional whitespace at start of cookie r"(?P<key>" # Start of group 'key' - ""+ _LegalCharsPatt +"+?" # Any word of at least one letter, nongreedy + "["+ _LegalKeyChars +"]+?" # Any word of at least one letter, nongreedy r")" # End of group 'key' r"(" # Optional group: there may not be a value. r"\s*=\s*" # Equal Sign @@ -542,7 +543,7 @@ _CookiePattern = re.compile( r"|" # or r"\w{3},\s[\s\w\d-]{9,11}\s[\d:]{8}\sGMT" # Special case for "expires" attr r"|" # or - ""+ _LegalCharsPatt +"*" # Any word or empty string + "["+ _LegalValueChars +"]*" # Any word or empty string r")" # End of group 'val' r")?" # End of optional value group r"\s*" # Any number of spaces. |
