mirror of
https://github.com/python/cpython.git
synced 2025-09-24 17:33:29 +00:00
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.
This commit is contained in:
parent
860c367c29
commit
dad182c16e
4 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue