summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-09-16 22:23:55 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-09-16 22:23:55 (GMT)
commit7d0b8f95e7c6cc70c1a636312099773376337d14 (patch)
treee3062b5036879bd2a96db7f5a19b52c15d8033d4 /Lib/http
parent89e186f24ea6c10c39e90eb153bf714934be4e62 (diff)
downloadcpython-7d0b8f95e7c6cc70c1a636312099773376337d14.zip
cpython-7d0b8f95e7c6cc70c1a636312099773376337d14.tar.gz
cpython-7d0b8f95e7c6cc70c1a636312099773376337d14.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.py3
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