# This issue has been offered to upstream and merged.
# Please see https://bitbucket.org/cherrypy/cherrypy/commits/89dbd2f00b541f8f8378eaabf2caef3e932bb805
# HG changeset patch
# User Yiteng Zhang <yiteng.zhang@oracle.com>
# Date 1461887965 25200
# Node ID 89dbd2f00b541f8f8378eaabf2caef3e932bb805
# Parent ea07b29deabd28d5a10b764a1a452c876692d028
parse_request_uri() incorrectly parses URI which contains ://
--- cherrypy/wsgiserver/wsgiserver2.py
+++ cherrypy/wsgiserver/wsgiserver2.py
@@ -92,6 +92,7 @@
import traceback as traceback_
import operator
from urllib import unquote
+from urlparse import urlparse
import warnings
import errno
import logging
@@ -830,15 +831,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):
--- cherrypy/wsgiserver/wsgiserver3.py
+++ cherrypy/wsgiserver/wsgiserver3.py
@@ -92,6 +92,8 @@
import traceback as traceback_
import errno
import logging
+from urllib.parse import urlparse
+
try:
# prefer slower Python-based io module
import _pyio as io
@@ -819,14 +821,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.