components/python/cherrypy/patches/cp-ticket-1386.patch
branchs11u3-sru14-backport
changeset 7281 084dbeea9c92
parent 7235 11e6a3bbf713
child 7282 eaaa4b66f543
equal deleted inserted replaced
7235:11e6a3bbf713 7281:084dbeea9c92
     1 # This issue has been offered to upstream and merged.
       
     2 # Please see https://bitbucket.org/cherrypy/cherrypy/commits/89dbd2f00b541f8f8378eaabf2caef3e932bb805
       
     3 # HG changeset patch
       
     4 # User Yiteng Zhang <[email protected]>
       
     5 # Date 1461887965 25200
       
     6 # Node ID 89dbd2f00b541f8f8378eaabf2caef3e932bb805
       
     7 # Parent  ea07b29deabd28d5a10b764a1a452c876692d028
       
     8 parse_request_uri() incorrectly parses URI which contains ://
       
     9 
       
    10 --- cherrypy/wsgiserver/wsgiserver2.py
       
    11 +++ cherrypy/wsgiserver/wsgiserver2.py
       
    12 @@ -92,6 +92,7 @@
       
    13  import traceback as traceback_
       
    14  import operator
       
    15  from urllib import unquote
       
    16 +from urlparse import urlparse
       
    17  import warnings
       
    18  import errno
       
    19  import logging
       
    20 @@ -830,15 +831,12 @@
       
    21          if uri == ASTERISK:
       
    22              return None, None, uri
       
    23  
       
    24 -        i = uri.find('://')
       
    25 -        if i > 0 and QUESTION_MARK not in uri[:i]:
       
    26 +        scheme, authority, path, params, query, fragment = urlparse(uri)
       
    27 +        if scheme and QUESTION_MARK not in scheme:
       
    28              # An absoluteURI.
       
    29              # If there's a scheme (and it must be http or https), then:
       
    30              # http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query
       
    31              # ]]
       
    32 -            scheme, remainder = uri[:i].lower(), uri[i + 3:]
       
    33 -            authority, path = remainder.split(FORWARD_SLASH, 1)
       
    34 -            path = FORWARD_SLASH + path
       
    35              return scheme, authority, path
       
    36  
       
    37          if uri.startswith(FORWARD_SLASH):
       
    38 --- cherrypy/wsgiserver/wsgiserver3.py
       
    39 +++ cherrypy/wsgiserver/wsgiserver3.py
       
    40 @@ -92,6 +92,8 @@
       
    41  import traceback as traceback_
       
    42  import errno
       
    43  import logging
       
    44 +from urllib.parse import urlparse
       
    45 +
       
    46  try:
       
    47      # prefer slower Python-based io module
       
    48      import _pyio as io
       
    49 @@ -819,14 +821,13 @@
       
    50          if uri == ASTERISK:
       
    51              return None, None, uri
       
    52  
       
    53 -        scheme, sep, remainder = uri.partition(b'://')
       
    54 -        if sep and QUESTION_MARK not in scheme:
       
    55 +        scheme, authority, path, params, query, fragment = urlparse(uri)
       
    56 +        if scheme and QUESTION_MARK not in scheme:
       
    57              # An absoluteURI.
       
    58              # If there's a scheme (and it must be http or https), then:
       
    59              # http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query
       
    60              # ]]
       
    61 -            authority, path_a, path_b = remainder.partition(FORWARD_SLASH)
       
    62 -            return scheme.lower(), authority, path_a + path_b
       
    63 +            return scheme, authority, path
       
    64  
       
    65          if uri.startswith(FORWARD_SLASH):
       
    66              # An abs_path.