diff options
author | Andrew M. Kuchling <amk@amk.ca> | 1999-01-06 22:13:09 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 1999-01-06 22:13:09 (GMT) |
commit | 5c355201e238c34916aceba597f1d3086ce29a7e (patch) | |
tree | f0a7127707a8990a3d00a3cc07b43a2b3cf6adf1 | |
parent | 2386d7333f9fa9fa35bde5faf3400146d5bb471b (diff) | |
download | cpython-5c355201e238c34916aceba597f1d3086ce29a7e.zip cpython-5c355201e238c34916aceba597f1d3086ce29a7e.tar.gz cpython-5c355201e238c34916aceba597f1d3086ce29a7e.tar.bz2 |
Fixed bug in the common-case code for HTTP URLs; it would lose the query,
fragment, and/or parameter information.
3 cases added to the test suite to check for this bug.
-rw-r--r-- | Lib/urlparse.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/urlparse.py b/Lib/urlparse.py index fe2c8de..148633e 100644 --- a/Lib/urlparse.py +++ b/Lib/urlparse.py @@ -54,7 +54,7 @@ def urlparse(url, scheme = '', allow_fragments = 1): netloc = path = params = query = fragment = '' i = find(url, ':') if i > 0: - if url[:i] == 'http': # optimizie the common case + if url[:i] == 'http': # optimize the common case scheme = string.lower(url[:i]) url = url[i+1:] if url[:2] == '//': @@ -66,16 +66,16 @@ def urlparse(url, scheme = '', allow_fragments = 1): if allow_fragments: i = string.rfind(url, '#') if i >= 0: - url = url[:i] fragment = url[i+1:] + url = url[:i] i = find(url, '?') if i >= 0: - url = url[:i] query = url[i+1:] + url = url[:i] i = find(url, ';') if i >= 0: - url = url[:i] params = url[i+1:] + url = url[:i] tuple = scheme, netloc, url, params, query, fragment _parse_cache[key] = tuple return tuple @@ -225,6 +225,9 @@ test_input = """ g/../h = <URL:http://a/b/c/h> http:g = <URL:http://a/b/c/g> http: = <URL:http://a/b/c/d> + http:?y = <URL:http://a/b/c/d?y> + http:g?y = <URL:http://a/b/c/g?y> + http:g?y/./x = <URL:http://a/b/c/g?y/./x> """ # XXX The result for //g is actually http://g/; is this a problem? |