Ticket #19101: 19101-2.diff

File 19101-2.diff, 1.9 KB (added by Claude Paroz, 12 years ago)

Updated patch

  • django/http/request.py

    diff --git a/django/http/request.py b/django/http/request.py
    index 96c7606..94bf51d 100644
    a b class HttpRequest(object):  
    224224                self._mark_post_parse_error()
    225225                raise
    226226        elif self.META.get('CONTENT_TYPE', '').startswith('application/x-www-form-urlencoded'):
    227             self._post, self._files = QueryDict(self.body, encoding=self._encoding), MultiValueDict()
     227            self._post, self._files = QueryDict(force_str(self.body), encoding=self._encoding), MultiValueDict()
    228228        else:
    229229            self._post, self._files = QueryDict('', encoding=self._encoding), MultiValueDict()
    230230
  • tests/regressiontests/requests/tests.py

    diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py
    index eaf25ea..164c108 100644
    a b from django.http import HttpRequest, HttpResponse, parse_cookie, build_request_r  
    1212from django.test.client import FakePayload
    1313from django.test.utils import override_settings, str_prefix
    1414from django.utils import unittest
    15 from django.utils.http import cookie_date
     15from django.utils.http import cookie_date, urlencode
    1616from django.utils.timezone import utc
    1717
    1818
    class RequestsTests(unittest.TestCase):  
    353353        self.assertRaises(Exception, lambda: request.body)
    354354        self.assertEqual(request.POST, {})
    355355
     356    def test_non_ascii_POST(self):
     357        payload = FakePayload(urlencode({'key': 'España'}))
     358        request = WSGIRequest({
     359            'REQUEST_METHOD': 'POST',
     360            'CONTENT_LENGTH': len(payload),
     361            'CONTENT_TYPE': 'application/x-www-form-urlencoded',
     362            'wsgi.input': payload,
     363        })
     364        self.assertEqual(request.POST, {'key': ['España']})
     365
    356366    def test_alternate_charset_POST(self):
    357367        """
    358368        Test a POST with non-utf-8 payload encoding.
Back to Top