summaryrefslogtreecommitdiffstats
path: root/Lib/urlparse.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-03-18 15:10:44 (GMT)
committerGuido van Rossum <guido@python.org>1999-03-18 15:10:44 (GMT)
commitf3963b1269a9f4fde99724524a7afe81e974aa62 (patch)
tree920604dd88959130b6e8e1b6fa74080fcf58e511 /Lib/urlparse.py
parente3fd1064debb7d7d8aa94dedef6f6d8c1e7166cc (diff)
downloadcpython-f3963b1269a9f4fde99724524a7afe81e974aa62.zip
cpython-f3963b1269a9f4fde99724524a7afe81e974aa62.tar.gz
cpython-f3963b1269a9f4fde99724524a7afe81e974aa62.tar.bz2
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.
Diffstat (limited to 'Lib/urlparse.py')
-rw-r--r--Lib/urlparse.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index 698b726..4552e6e 100644
--- a/Lib/urlparse.py
+++ b/Lib/urlparse.py
@@ -112,9 +112,9 @@ def urlparse(url, scheme = '', allow_fragments = 1):
# had redundant delimiters, e.g. a ? with an empty query (the draft
# states that these are equivalent).
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
- url = '//' + netloc + url
+ url = '//' + (netloc or '') + url
if scheme:
url = scheme + ':' + url
if params: