cp-ticket-1386.patch revision 5107
# This issue has been offered to upstream but not be accepted yet.
# Please see https://bitbucket.org/cherrypy/cherrypy/issues/1386/parse_request_uri-incorrectly-parses-uri
diff -r 252fccc270d4 cherrypy/wsgiserver/wsgiserver2.py
--- cherrypy/wsgiserver/wsgiserver2.py Tue Sep 01 12:23:22 2015 +0100
+++ cherrypy/wsgiserver/wsgiserver2.py Thu Oct 22 23:16:55 2015 -0700
@@ -125,6 +125,7 @@
import operator
from urllib import unquote
+from urlparse import urlparse
import warnings
if sys.version_info >= (3, 0):
@@ -835,15 +836,12 @@
if uri == ASTERISK:
return None, None, uri
- i = uri.find('://')
- if i > 0 and QUESTION_MARK not in uri[:i]:
+ scheme, authority, path, params, query, fragment = urlparse(uri)
+ if scheme and QUESTION_MARK not in scheme:
# An absoluteURI.
# If there's a scheme (and it must be http or https), then:
# http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query
# ]]
- scheme, remainder = uri[:i].lower(), uri[i + 3:]
- authority, path = remainder.split(FORWARD_SLASH, 1)
- path = FORWARD_SLASH + path
return scheme, authority, path
if uri.startswith(FORWARD_SLASH):
diff -r 252fccc270d4 cherrypy/wsgiserver/wsgiserver3.py
--- cherrypy/wsgiserver/wsgiserver3.py Tue Sep 01 12:23:22 2015 +0100
+++ cherrypy/wsgiserver/wsgiserver3.py Thu Oct 22 23:16:55 2015 -0700
@@ -100,6 +100,7 @@
import threading
import time
from traceback import format_exc
+from urllib.parse import urlparse
if sys.version_info >= (3, 0):
bytestr = bytes
@@ -813,14 +814,13 @@
if uri == ASTERISK:
return None, None, uri
- scheme, sep, remainder = uri.partition(b'://')
- if sep and QUESTION_MARK not in scheme:
+ scheme, authority, path, params, query, fragment = urlparse(uri)
+ if scheme and QUESTION_MARK not in scheme:
# An absoluteURI.
# If there's a scheme (and it must be http or https), then:
# http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query
# ]]
- authority, path_a, path_b = remainder.partition(FORWARD_SLASH)
- return scheme.lower(), authority, path_a + path_b
+ return scheme, authority, path
if uri.startswith(FORWARD_SLASH):
# An abs_path.