]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patches by Michael Reilly to correctly deal with ftp URLs of the form
authorGuido van Rossum <guido@python.org>
Wed, 18 Aug 1999 17:40:33 +0000 (17:40 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 18 Aug 1999 17:40:33 +0000 (17:40 +0000)
ftp://user@host//root/path: the double slash in the pathname means to
go to the root directory even if the initial directory isn't the root.

Lib/urllib.py

index ad1e791386ccfdbc740d2db24600c089e20306f6..4bd329f2645dcbddb8f69aaa96fe12a8f446ddcc 100644 (file)
@@ -362,6 +362,7 @@ class URLopener:
         dirs = string.splitfields(path, '/')
         dirs, file = dirs[:-1], dirs[-1]
         if dirs and not dirs[0]: dirs = dirs[1:]
+        if dirs and not dirs[0]: dirs[0] = '/'
         key = (user, host, port, string.joinfields(dirs, '/'))
         # XXX thread unsafe!
         if len(self.ftpcache) > MAXFTPCACHE: