diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2010-01-23 23:25:41 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2010-01-23 23:25:41 +0000 |
| commit | a3f4402853b7beb7a89cc88a1500818f94f8d313 (patch) | |
| tree | 56d48da64ed5ad7e7adf734e21469d20fab5b7b9 /tests/regressiontests | |
| parent | da954e876b75be18b5635aa553af17e791971445 (diff) | |
[1.1.X] Fixed #12470 - encoding of comma and semi-colon in cookies.
This is a backport of r12282 from trunk.
The original bug was about CookieStorage, which does not exist in 1.1.X,
but the fix involved the underlying cookie storage.
The change fixes other bugs with cookies for Internet Explorer and Safari,
hence it is backported. It could, however, also cause backwards
incompatibilities with existing javascript that may parse cookie values that
contain commas or semi-colons, and, very rarely, with existing cookie values
manipulated server side.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12283 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/httpwrappers/tests.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py index 04099be16e..09da4476b4 100644 --- a/tests/regressiontests/httpwrappers/tests.py +++ b/tests/regressiontests/httpwrappers/tests.py @@ -465,7 +465,40 @@ BadHeaderError: Header values can't contain newlines (got 'test\\nstr') [u'1', u'2', u'3', u'4'] """ -from django.http import QueryDict, HttpResponse +from django.http import QueryDict, HttpResponse, CompatCookie +from django.test import TestCase + + +class Cookies(TestCase): + + def test_encode(self): + """ + Test that we don't output tricky characters in encoded value + """ + c = CompatCookie() + c['test'] = "An,awkward;value" + self.assert_(";" not in c.output()) # IE compat + self.assert_("," not in c.output()) # Safari compat + + def test_decode(self): + """ + Test that we can still preserve semi-colons and commas + """ + c = CompatCookie() + c['test'] = "An,awkward;value" + c2 = CompatCookie() + c2.load(c.output()) + self.assertEqual(c['test'].value, c2['test'].value) + + def test_decode_2(self): + """ + Test that we haven't broken normal encoding + """ + c = CompatCookie() + c['test'] = "\xf0" + c2 = CompatCookie() + c2.load(c.output()) + self.assertEqual(c['test'].value, c2['test'].value) if __name__ == "__main__": import doctest |
