Ticket #15852: 15852_repeated_bad_cookie_name.diff

File 15852_repeated_bad_cookie_name.diff, 1.7 KB (added by vung, 14 years ago)

Fix failure when a bad cookie name is repeated

  • tests/regressiontests/httpwrappers/tests.py

     
    281281        Test that a single non-standard cookie name doesn't affect all cookies. Ticket #13007.
    282282        """
    283283        self.assertTrue('good_cookie' in parse_cookie('good_cookie=yes;bad:cookie=yes').keys())
     284
     285    def test_repeated_nonstandard_keys(self):
     286        """
     287        Test that a repeated non-standard name doesn't affect all cookies. Ticket #15852
     288        """
     289        self.assertTrue('good_cookie' in parse_cookie('a,=b; a,=c; good_cookie=yes').keys())
  • django/http/__init__.py

     
    9292        if not _cookie_allows_colon_in_names:
    9393            def load(self, rawdata, ignore_parse_errors=False):
    9494                if ignore_parse_errors:
    95                     self.bad_cookies = []
     95                    self.bad_cookies = set()
    9696                    self._BaseCookie__set = self._loose_set
    9797                super(SimpleCookie, self).load(rawdata)
    9898                if ignore_parse_errors:
     
    106106                try:
    107107                    self._strict_set(key, real_value, coded_value)
    108108                except Cookie.CookieError:
    109                     self.bad_cookies.append(key)
    110                     dict.__setitem__(self, key, None)
     109                    self.bad_cookies.add(key)
     110                    dict.__setitem__(self, key, Cookie.Morsel())
    111111
    112112
    113113class CompatCookie(SimpleCookie):
Back to Top