summaryrefslogtreecommitdiff
path: root/django/http/request.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/http/request.py')
-rw-r--r--django/http/request.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/django/http/request.py b/django/http/request.py
index c87a4c5125..e251e62b66 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -329,8 +329,12 @@ class QueryDict(MultiValueDict):
self.encoding = encoding
if six.PY3:
if isinstance(query_string, bytes):
- # query_string contains URL-encoded data, a subset of ASCII.
- query_string = query_string.decode()
+ # query_string normally contains URL-encoded data, a subset of ASCII.
+ try:
+ query_string = query_string.decode(encoding)
+ except UnicodeDecodeError:
+ # ... but some user agents are misbehaving :-(
+ query_string = query_string.decode('iso-8859-1')
for key, value in parse_qsl(query_string or '',
keep_blank_values=True,
encoding=encoding):
@@ -338,8 +342,12 @@ class QueryDict(MultiValueDict):
else:
for key, value in parse_qsl(query_string or '',
keep_blank_values=True):
+ try:
+ value = value.decode(encoding)
+ except UnicodeDecodeError:
+ value = value.decode('iso-8859-1')
self.appendlist(force_text(key, encoding, errors='replace'),
- force_text(value, encoding, errors='replace'))
+ value)
self._mutable = mutable
@property