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