diff --git a/django/http/__init__.py b/django/http/__init__.py index 2a88ee1950..cf1eb0d9e2 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -91,7 +91,7 @@ else: if not _cookie_allows_colon_in_names: def load(self, rawdata, ignore_parse_errors=False): if ignore_parse_errors: - self.bad_cookies = [] + self.bad_cookies = set() self._BaseCookie__set = self._loose_set super(SimpleCookie, self).load(rawdata) if ignore_parse_errors: @@ -105,8 +105,8 @@ else: try: self._strict_set(key, real_value, coded_value) except Cookie.CookieError: - self.bad_cookies.append(key) - dict.__setitem__(self, key, None) + self.bad_cookies.add(key) + dict.__setitem__(self, key, Cookie.Morsel()) class CompatCookie(SimpleCookie): diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py index 493109a38e..2a5eddc661 100644 --- a/tests/regressiontests/httpwrappers/tests.py +++ b/tests/regressiontests/httpwrappers/tests.py @@ -285,3 +285,9 @@ class CookieTests(unittest.TestCase): Test that a single non-standard cookie name doesn't affect all cookies. Ticket #13007. """ self.assertTrue('good_cookie' in parse_cookie('good_cookie=yes;bad:cookie=yes').keys()) + + def test_repeated_nonstandard_keys(self): + """ + Test that a repeated non-standard name doesn't affect all cookies. Ticket #15852 + """ + self.assertTrue('good_cookie' in parse_cookie('a,=b; a,=c; good_cookie=yes').keys())