1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #19101 -- Decoding of non-ASCII POST data on Python 3.

Thanks Claude Paroz.
This commit is contained in:
Aymeric Augustin
2012-11-03 12:54:06 +01:00
parent ac2052ebc8
commit 095eca8dd8
3 changed files with 15 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ from django.http import HttpRequest, HttpResponse, parse_cookie, build_request_r
from django.test.client import FakePayload
from django.test.utils import override_settings, str_prefix
from django.utils import unittest
from django.utils.http import cookie_date
from django.utils.http import cookie_date, urlencode
from django.utils.timezone import utc
@@ -353,6 +353,16 @@ class RequestsTests(unittest.TestCase):
self.assertRaises(Exception, lambda: request.body)
self.assertEqual(request.POST, {})
def test_non_ascii_POST(self):
payload = FakePayload(urlencode({'key': 'España'}))
request = WSGIRequest({
'REQUEST_METHOD': 'POST',
'CONTENT_LENGTH': len(payload),
'CONTENT_TYPE': 'application/x-www-form-urlencoded',
'wsgi.input': payload,
})
self.assertEqual(request.POST, {'key': ['España']})
def test_alternate_charset_POST(self):
"""
Test a POST with non-utf-8 payload encoding.