summaryrefslogtreecommitdiffstats
path: root/Lib/test
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/test
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/test')
-rw-r--r--Lib/test/test_http_cookies.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py
index 1cfbe74..76e5e9c 100644
--- a/Lib/test/test_http_cookies.py
+++ b/Lib/test/test_http_cookies.py
@@ -179,6 +179,15 @@ class CookieTests(unittest.TestCase):
</script>
""")
+ def test_invalid_cookies(self):
+ # Accepting these could be a security issue
+ C = cookies.SimpleCookie()
+ for s in (']foo=x', '[foo=x', 'blah]foo=x', 'blah[foo=x'):
+ C.load(s)
+ self.assertEqual(dict(C), {})
+ self.assertEqual(C.output(), '')
+
+
class MorselTests(unittest.TestCase):
"""Tests for the Morsel object."""