Use a WSGI "bytes-as-unicode" string for PATH_INFO under Python 3.

This commit is contained in:
Andreas Stührk 2013-05-18 00:11:02 +02:00 committed by benoitc
parent ca35dc7335
commit fa7fd6fed0
2 changed files with 7 additions and 5 deletions

View File

@ -8,8 +8,7 @@ import os
import re
import sys
from gunicorn.six import (unquote, string_types, binary_type, reraise,
text_type)
from gunicorn.six import unquote_to_wsgi_str, string_types, binary_type, reraise
from gunicorn import SERVER_SOFTWARE
import gunicorn.util as util
@ -164,7 +163,7 @@ def create(req, sock, client, server, cfg):
path_info = req.path
if script_name:
path_info = path_info.split(script_name, 1)[1]
environ['PATH_INFO'] = unquote(path_info)
environ['PATH_INFO'] = unquote_to_wsgi_str(path_info)
environ['SCRIPT_NAME'] = script_name
environ.update(proxy_environ(req))

View File

@ -387,7 +387,10 @@ if PY3:
import urllib.parse
unquote = urllib.parse.unquote
def unquote_to_wsgi_str(string):
return _unquote_to_bytes(string).decode('latin-1')
_unquote_to_bytes = urllib.parse.unquote_to_bytes
urlsplit = urllib.parse.urlsplit
urlparse = urllib.parse.urlparse
@ -402,4 +405,4 @@ else:
urlparse = orig_urlparse.urlparse
import urllib
unquote = urllib.unquote
unquote_to_wsgi_str = urllib.unquote