summaryrefslogtreecommitdiffstats
path: root/Lib/http/cookies.py
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)
commitdad182c16e6c9d10267a659bd376ba3d10affd4f (patch)
treec70767003a273334c2c4bc9d4773c2a087beb97a /Lib/http/cookies.py
parent860c367c29eb557930099a7cc7fe297a259275f6 (diff)
downloadcpython-dad182c16e6c9d10267a659bd376ba3d10affd4f.zip
cpython-dad182c16e6c9d10267a659bd376ba3d10affd4f.tar.gz
cpython-dad182c16e6c9d10267a659bd376ba3d10affd4f.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/cookies.py')
-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 ddbcbf8..28c1161 100644
--- a/Lib/http/cookies.py
+++ b/Lib/http/cookies.py
@@ -432,6 +432,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'
@@ -532,7 +533,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