Show More
@@ -7,7 +7,7 b'' | |||||
7 | # This software may be used and distributed according to the terms of the |
|
7 | # This software may be used and distributed according to the terms of the | |
8 | # GNU General Public License version 2 or any later version. |
|
8 | # GNU General Public License version 2 or any later version. | |
9 |
|
9 | |||
10 | import urllib, urllib2, httplib, os, socket, cStringIO |
|
10 | import urllib, urllib2, httplib, os, socket, cStringIO, re | |
11 | import __builtin__ |
|
11 | import __builtin__ | |
12 | from i18n import _ |
|
12 | from i18n import _ | |
13 | import keepalive, util |
|
13 | import keepalive, util | |
@@ -64,6 +64,7 b' class url(object):' | |||||
64 |
|
64 | |||
65 | _safechars = "!~*'()+" |
|
65 | _safechars = "!~*'()+" | |
66 | _safepchars = "/!~*'()+" |
|
66 | _safepchars = "/!~*'()+" | |
|
67 | _matchscheme = re.compile(r'^[a-zA-Z0-9+.\-]+:').match | |||
67 |
|
68 | |||
68 | def __init__(self, path, parsequery=True, parsefragment=True): |
|
69 | def __init__(self, path, parsequery=True, parsefragment=True): | |
69 | # We slowly chomp away at path until we have only the path left |
|
70 | # We slowly chomp away at path until we have only the path left | |
@@ -88,7 +89,7 b' class url(object):' | |||||
88 | self.path = path |
|
89 | self.path = path | |
89 | return |
|
90 | return | |
90 |
|
91 | |||
91 | if not path.startswith('/') and ':' in path: |
|
92 | if self._matchscheme(path): | |
92 | parts = path.split(':', 1) |
|
93 | parts = path.split(':', 1) | |
93 | if parts[0]: |
|
94 | if parts[0]: | |
94 | self.scheme, path = parts |
|
95 | self.scheme, path = parts |
@@ -157,6 +157,12 b' def test_url():' | |||||
157 | <url path: 'a/b/c/d.g.f'> |
|
157 | <url path: 'a/b/c/d.g.f'> | |
158 | >>> url('/x///z/y/') |
|
158 | >>> url('/x///z/y/') | |
159 | <url path: '/x///z/y/'> |
|
159 | <url path: '/x///z/y/'> | |
|
160 | >>> url('/foo:bar') | |||
|
161 | <url path: '/foo:bar'> | |||
|
162 | >>> url('\\\\foo:bar') | |||
|
163 | <url path: '\\\\foo:bar'> | |||
|
164 | >>> url('./foo:bar') | |||
|
165 | <url path: './foo:bar'> | |||
160 |
|
166 | |||
161 | Non-localhost file URL: |
|
167 | Non-localhost file URL: | |
162 |
|
168 |
General Comments 0
You need to be logged in to leave comments.
Login now