Kaydet (Commit) f3963b12 authored tarafından Guido van Rossum's avatar Guido van Rossum

Sjoerd Mullender writes:

If a filename on Windows starts with \\, it is converted to a URL
which starts with ////.  If this URL is passed to urlparse.urlparse
you get a path that starts with // (and an empty netloc).  If you pass
the result back to urlparse.urlunparse, you get a URL that starts with
//, which is parsed differently by urlparse.urlparse.  The fix is to
add the (empty) netloc with accompanying slashes if the path in
urlunparse starts with //.  Do this for all schemes that use a netloc.
üst e3fd1064
...@@ -112,9 +112,9 @@ def urlparse(url, scheme = '', allow_fragments = 1): ...@@ -112,9 +112,9 @@ def urlparse(url, scheme = '', allow_fragments = 1):
# had redundant delimiters, e.g. a ? with an empty query (the draft # had redundant delimiters, e.g. a ? with an empty query (the draft
# states that these are equivalent). # states that these are equivalent).
def urlunparse((scheme, netloc, url, params, query, fragment)): def urlunparse((scheme, netloc, url, params, query, fragment)):
if netloc: if netloc or (scheme in uses_netloc and url[:2] == '//'):
if url[:1] != '/': url = '/' + url if url[:1] != '/': url = '/' + url
url = '//' + netloc + url url = '//' + (netloc or '') + url
if scheme: if scheme:
url = scheme + ':' + url url = scheme + ':' + url
if params: if params:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment