mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #3924: Ignore cookies with invalid "version" field in cookielib.
This commit is contained in:
parent
f93ce0c1f5
commit
5d0ca2c832
3 changed files with 32 additions and 6 deletions
|
@ -99,7 +99,8 @@ class DateTimeTests(TestCase):
|
|||
|
||||
|
||||
class HeaderTests(TestCase):
|
||||
def test_parse_ns_headers(self):
|
||||
|
||||
def test_parse_ns_headers_expires(self):
|
||||
from cookielib import parse_ns_headers
|
||||
|
||||
# quotes should be stripped
|
||||
|
@ -110,6 +111,17 @@ class HeaderTests(TestCase):
|
|||
]:
|
||||
self.assertEquals(parse_ns_headers([hdr]), expected)
|
||||
|
||||
def test_parse_ns_headers_version(self):
|
||||
from cookielib import parse_ns_headers
|
||||
|
||||
# quotes should be stripped
|
||||
expected = [[('foo', 'bar'), ('version', '1')]]
|
||||
for hdr in [
|
||||
'foo=bar; version="1"',
|
||||
'foo=bar; Version="1"',
|
||||
]:
|
||||
self.assertEquals(parse_ns_headers([hdr]), expected)
|
||||
|
||||
def test_parse_ns_headers_special_names(self):
|
||||
# names such as 'expires' are not special in first name=value pair
|
||||
# of Set-Cookie: header
|
||||
|
@ -1091,6 +1103,8 @@ class CookieTests(TestCase):
|
|||
["Set-Cookie2: a=foo; path=/; Version=1; domain"],
|
||||
# bad max-age
|
||||
["Set-Cookie: b=foo; max-age=oops"],
|
||||
# bad version
|
||||
["Set-Cookie: b=foo; version=spam"],
|
||||
]:
|
||||
c = cookiejar_from_cookie_headers(headers)
|
||||
# these bad cookies shouldn't be set
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue