summaryrefslogtreecommitdiff
path: root/tests/regressiontests/requests/tests.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-10-29 20:33:00 +0100
committerClaude Paroz <claude@2xlibre.net>2012-10-30 09:00:32 +0100
commit6de6988f9990b4b53f5a20bfc3811b3cc49291c5 (patch)
tree7ea2c720c81f98ea5ee68bd67e79942ba20aef91 /tests/regressiontests/requests/tests.py
parent9741912a9aaad083eaa8b9780cde37e1843cc4ae (diff)
Fixed #5076 -- Properly decode POSTs with non-utf-8 payload encoding
Thanks daniel at blogg.se for the report and Aymeric Augustin for his assistance on the patch.
Diffstat (limited to 'tests/regressiontests/requests/tests.py')
-rw-r--r--tests/regressiontests/requests/tests.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py
index 6522620d5f..eaf25ea7a6 100644
--- a/tests/regressiontests/requests/tests.py
+++ b/tests/regressiontests/requests/tests.py
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
import time
@@ -352,6 +353,20 @@ class RequestsTests(unittest.TestCase):
self.assertRaises(Exception, lambda: request.body)
self.assertEqual(request.POST, {})
+ def test_alternate_charset_POST(self):
+ """
+ Test a POST with non-utf-8 payload encoding.
+ """
+ from django.utils.http import urllib_parse
+ payload = FakePayload(urllib_parse.urlencode({'key': 'España'.encode('latin-1')}))
+ request = WSGIRequest({
+ 'REQUEST_METHOD': 'POST',
+ 'CONTENT_LENGTH': len(payload),
+ 'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=iso-8859-1',
+ 'wsgi.input': payload,
+ })
+ self.assertEqual(request.POST, {'key': ['España']})
+
def test_body_after_POST_multipart(self):
"""
Reading body after parsing multipart is not allowed