Issue #20138: The wsgiref.application_uri() and wsgiref.request_uri()

functions now conform to PEP 3333 when handle non-ASCII URLs.
This commit is contained in:
Serhiy Storchaka 2014-01-12 12:08:11 +02:00
parent 55c9e0366e
commit 0abbe8c090
3 changed files with 11 additions and 4 deletions

View file

@ -57,14 +57,14 @@ def application_uri(environ):
if environ['SERVER_PORT'] != '80':
url += ':' + environ['SERVER_PORT']
url += quote(environ.get('SCRIPT_NAME') or '/')
url += quote(environ.get('SCRIPT_NAME') or '/', encoding='latin1')
return url
def request_uri(environ, include_query=True):
"""Return the full request URI, optionally including the query string"""
url = application_uri(environ)
from urllib.parse import quote
path_info = quote(environ.get('PATH_INFO',''),safe='/;=,')
path_info = quote(environ.get('PATH_INFO',''), safe='/;=,', encoding='latin1')
if not environ.get('SCRIPT_NAME'):
url += path_info[1:]
else: