components/python/cherrypy/patches/cp-ticket-1386.patch
changeset 5109 5d341c4a6b80
child 5947 d9fcc08e98bf
equal deleted inserted replaced
5108:0546c7178c66 5109:5d341c4a6b80
       
     1 # This issue has been offered to upstream but not be accepted yet.
       
     2 # Please see https://bitbucket.org/cherrypy/cherrypy/issues/1386/parse_request_uri-incorrectly-parses-uri
       
     3 
       
     4 diff -r 252fccc270d4 cherrypy/wsgiserver/wsgiserver2.py
       
     5 --- cherrypy/wsgiserver/wsgiserver2.py	Tue Sep 01 12:23:22 2015 +0100
       
     6 +++ cherrypy/wsgiserver/wsgiserver2.py	Thu Oct 22 23:16:55 2015 -0700
       
     7 @@ -125,6 +125,7 @@
       
     8  import operator
       
     9  
       
    10  from urllib import unquote
       
    11 +from urlparse import urlparse
       
    12  import warnings
       
    13  
       
    14  if sys.version_info >= (3, 0):
       
    15 @@ -835,15 +836,12 @@
       
    16          if uri == ASTERISK:
       
    17              return None, None, uri
       
    18  
       
    19 -        i = uri.find('://')
       
    20 -        if i > 0 and QUESTION_MARK not in uri[:i]:
       
    21 +        scheme, authority, path, params, query, fragment = urlparse(uri)
       
    22 +        if scheme and QUESTION_MARK not in scheme:
       
    23              # An absoluteURI.
       
    24              # If there's a scheme (and it must be http or https), then:
       
    25              # http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query
       
    26              # ]]
       
    27 -            scheme, remainder = uri[:i].lower(), uri[i + 3:]
       
    28 -            authority, path = remainder.split(FORWARD_SLASH, 1)
       
    29 -            path = FORWARD_SLASH + path
       
    30              return scheme, authority, path
       
    31  
       
    32          if uri.startswith(FORWARD_SLASH):
       
    33 diff -r 252fccc270d4 cherrypy/wsgiserver/wsgiserver3.py
       
    34 --- cherrypy/wsgiserver/wsgiserver3.py	Tue Sep 01 12:23:22 2015 +0100
       
    35 +++ cherrypy/wsgiserver/wsgiserver3.py	Thu Oct 22 23:16:55 2015 -0700
       
    36 @@ -100,6 +100,7 @@
       
    37  import threading
       
    38  import time
       
    39  from traceback import format_exc
       
    40 +from urllib.parse import urlparse
       
    41  
       
    42  if sys.version_info >= (3, 0):
       
    43      bytestr = bytes
       
    44 @@ -813,14 +814,13 @@
       
    45          if uri == ASTERISK:
       
    46              return None, None, uri
       
    47  
       
    48 -        scheme, sep, remainder = uri.partition(b'://')
       
    49 -        if sep and QUESTION_MARK not in scheme:
       
    50 +        scheme, authority, path, params, query, fragment = urlparse(uri)
       
    51 +        if scheme and QUESTION_MARK not in scheme:
       
    52              # An absoluteURI.
       
    53              # If there's a scheme (and it must be http or https), then:
       
    54              # http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query
       
    55              # ]]
       
    56 -            authority, path_a, path_b = remainder.partition(FORWARD_SLASH)
       
    57 -            return scheme.lower(), authority, path_a + path_b
       
    58 +            return scheme, authority, path
       
    59  
       
    60          if uri.startswith(FORWARD_SLASH):
       
    61              # An abs_path.