Author: ramiro
Date: 2011-06-25 09:18:40 -0700 (Sat, 25 Jun 2011)
New Revision: 16452
Modified:
django/trunk/django/http/__init__.py
django/trunk/tests/regressiontests/httpwrappers/tests.py
Log:
Fixed #15852 -- Modified cookie parsing so it can handle duplicate invalid
cookie names. Thanks goes to Fredrik St?\195?\165lnacke for the report and to
vung for the patch.
Modified: django/trunk/django/http/__init__.py
===================================================================
--- django/trunk/django/http/__init__.py 2011-06-25 13:14:31 UTC (rev
16451)
+++ django/trunk/django/http/__init__.py 2011-06-25 16:18:40 UTC (rev
16452)
@@ -91,7 +91,7 @@
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 @@
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):
Modified: django/trunk/tests/regressiontests/httpwrappers/tests.py
===================================================================
--- django/trunk/tests/regressiontests/httpwrappers/tests.py 2011-06-25
13:14:31 UTC (rev 16451)
+++ django/trunk/tests/regressiontests/httpwrappers/tests.py 2011-06-25
16:18:40 UTC (rev 16452)
@@ -285,3 +285,9 @@
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())
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.