mirror of
https://github.com/django/daphne.git
synced 2025-02-16 16:30:33 +03:00
Intepret + in query string section as a space
This commit is contained in:
parent
734fd8dbd3
commit
66e005f277
|
@ -5,7 +5,7 @@ import six
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from six.moves.urllib_parse import unquote
|
from six.moves.urllib_parse import unquote, unquote_plus
|
||||||
from twisted.protocols.policies import ProtocolWrapper
|
from twisted.protocols.policies import ProtocolWrapper
|
||||||
from twisted.web import http
|
from twisted.web import http
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class WebRequest(http.Request):
|
||||||
"method": self.method.decode("ascii"),
|
"method": self.method.decode("ascii"),
|
||||||
"path": self.unquote(self.path),
|
"path": self.unquote(self.path),
|
||||||
"scheme": "http",
|
"scheme": "http",
|
||||||
"query_string": self.unquote(self.query_string),
|
"query_string": self.unquote(self.query_string, plus_as_space=True),
|
||||||
"headers": self.clean_headers,
|
"headers": self.clean_headers,
|
||||||
"body": self.content.read(),
|
"body": self.content.read(),
|
||||||
"client": self.client_addr,
|
"client": self.client_addr,
|
||||||
|
@ -142,14 +142,20 @@ class WebRequest(http.Request):
|
||||||
self.basic_error(500, b"Internal Server Error", "HTTP processing error")
|
self.basic_error(500, b"Internal Server Error", "HTTP processing error")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def unquote(cls, value):
|
def unquote(cls, value, plus_as_space=False):
|
||||||
"""
|
"""
|
||||||
Python 2 and 3 compat layer for utf-8 unquoting
|
Python 2 and 3 compat layer for utf-8 unquoting
|
||||||
"""
|
"""
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
return unquote(value).decode("utf8")
|
if plus_as_space:
|
||||||
|
return unquote_plus(value).decode("utf8")
|
||||||
|
else:
|
||||||
|
return unquote(value).decode("utf8")
|
||||||
else:
|
else:
|
||||||
return unquote(value.decode("ascii"))
|
if plus_as_space:
|
||||||
|
return unquote_plus(value.decode("ascii"))
|
||||||
|
else:
|
||||||
|
return unquote(value.decode("ascii"))
|
||||||
|
|
||||||
def send_disconnect(self):
|
def send_disconnect(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user