cpython: a065ab1c67a8 (original) (raw)

Mercurial > cpython

changeset 93524:a065ab1c67a8

Issue #22796: HTTP cookie parsing is now stricter, in order to protect against potential injection attacks. [#22796]

Antoine Pitrou solipsis@pitrou.net
date Fri, 21 Nov 2014 01:20:57 +0100
parents 7ce62e80d3cd
children 31fd106bb68a
files Lib/http/cookies.py Lib/test/test_http_cookies.py Misc/NEWS
diffstat 3 files changed, 48 insertions(+), 23 deletions(-)[+] [-] Lib/http/cookies.py 56 Lib/test/test_http_cookies.py 12 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -533,10 +533,17 @@ class BaseCookie(dict): return def __parse_string(self, str, patt=_CookiePattern):

+

@@ -547,22 +554,41 @@ class BaseCookie(dict): key, value = match.group("key"), match.group("val") i = match.end(0)

+

--- a/Lib/test/test_http_cookies.py +++ b/Lib/test/test_http_cookies.py @@ -141,13 +141,6 @@ class CookieTests(unittest.TestCase): self.assertEqual(C['eggs']['httponly'], 'foo') self.assertEqual(C['eggs']['secure'], 'bar')

- def test_extra_spaces(self): C = cookies.SimpleCookie() C.load('eggs = scrambled ; secure ; path = bar ; foo=foo ') @@ -182,7 +175,10 @@ class CookieTests(unittest.TestCase): def test_invalid_cookies(self): # Accepting these could be a security issue C = cookies.SimpleCookie()

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -188,6 +188,9 @@ Core and Builtins Library ------- +- Issue #22796: HTTP cookie parsing is now stricter, in order to protect