diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-09-16 22:27:26 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-09-16 22:27:26 (GMT) |
commit | 0d548873262d1e61f6089eccf43e261b259ec96e (patch) | |
tree | c98a2ac170b77dc8fd632f43d7143985f48abe33 /Lib/http | |
parent | a37b958d6540be7bb3cf181e448f1267c0e2824c (diff) | |
parent | 637e4544afda57d52c81bddba5486bda9574e6b2 (diff) | |
download | cpython-0d548873262d1e61f6089eccf43e261b259ec96e.zip cpython-0d548873262d1e61f6089eccf43e261b259ec96e.tar.gz cpython-0d548873262d1e61f6089eccf43e261b259ec96e.tar.bz2 |
Lax cookie parsing in http.cookies could be a security issue when combined
with non-standard cookie handling in some Web browsers.
Reported by Sergey Bobrov.
Diffstat (limited to 'Lib/http')
-rw-r--r-- | Lib/http/cookies.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index 24da5f4..556d101 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -431,6 +431,7 @@ class Morsel(dict): _LegalCharsPatt = r"[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]" _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 ) # End of group 'key' @@ -534,7 +535,7 @@ class BaseCookie(dict): while 0 <= i < n: # Start looking for a cookie - match = patt.search(str, i) + match = patt.match(str, i) if not match: # No more cookies break |