mirror of
https://github.com/django/django.git
synced 2025-10-29 00:26:07 +00:00
[1.6.x] Fixed #22996 -- Prevented crash with unencoded query string
Thanks Jorge Carleitao for the report and Aymeric Augustin, Tim Graham
for the reviews.
Backport of fa02120d36 from master.
This commit is contained in:
@@ -134,7 +134,7 @@ class WSGIRequest(http.HttpRequest):
|
||||
# The WSGI spec says 'QUERY_STRING' may be absent.
|
||||
raw_query_string = self.environ.get('QUERY_STRING', str(''))
|
||||
if six.PY3:
|
||||
raw_query_string = raw_query_string.encode('iso-8859-1').decode('utf-8')
|
||||
raw_query_string = raw_query_string.encode('iso-8859-1')
|
||||
self._get = http.QueryDict(raw_query_string, encoding=self._encoding)
|
||||
return self._get
|
||||
|
||||
|
||||
@@ -290,8 +290,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):
|
||||
|
||||
Reference in New Issue
Block a user