summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-03-18 14:21:41 (GMT)
committerGuido van Rossum <guido@python.org>1999-03-18 14:21:41 (GMT)
commita0fec1637b88fd63849b1810874714d4f1d09000 (patch)
tree1fe6d68a0bba1ef532f30f59989c0dd52ba259f5 /Lib
parent81da9f146c2223bc486197c2df03feda5126dcd5 (diff)
downloadcpython-a0fec1637b88fd63849b1810874714d4f1d09000.zip
cpython-a0fec1637b88fd63849b1810874714d4f1d09000.tar.gz
cpython-a0fec1637b88fd63849b1810874714d4f1d09000.tar.bz2
Sjoerd Mullender writes:
Pathnames of files on other hosts in the same domain (\\host\path\to\file) are not translated correctly to URLs and back. The URL should be something like file:////host/path/to/file. Note that a combination of drive letter and remote host is not possible.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/nturl2path.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/nturl2path.py b/Lib/nturl2path.py
index d86bbc2..8c02049 100644
--- a/Lib/nturl2path.py
+++ b/Lib/nturl2path.py
@@ -13,6 +13,11 @@ def url2pathname(url):
import string, urllib
if not '|' in url:
# No drive specifier, just convert slashes
+ if url[:4] == '////':
+ # path is something like ////host/path/on/remote/host
+ # convert this to \\host\path\on\remote\host
+ # (notice halving of slashes at the start of the path)
+ url = url[2:]
components = string.split(url, '/')
# make sure not to convert quoted slashes :-)
return urllib.unquote(string.join(components, '\\'))
@@ -41,6 +46,11 @@ def pathname2url(p):
import string, urllib
if not ':' in p:
# No drive specifier, just convert slashes and quote the name
+ if p[:2] == '\\\\':
+ # path is something like \\host\path\on\remote\host
+ # convert this to ////host/path/on/remote/host
+ # (notice doubling of slashes at the start of the path)
+ p = '\\\\' + p
components = string.split(p, '\\')
return urllib.quote(string.join(components, '/'))
comp = string.split(p, ':')