]> granicus.if.org Git - python/commitdiff
(Jack+Guido:) interpret ../ in basejoin() according to RFC1808.
authorGuido van Rossum <guido@python.org>
Fri, 11 Apr 1997 19:09:51 +0000 (19:09 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 11 Apr 1997 19:09:51 +0000 (19:09 +0000)
Lib/urllib.py

index e57311b519b5105d5c2788e56e038409ccc80cc4..a8a579bb90617748cbae52a8e64d7b1aa45192c5 100644 (file)
@@ -592,6 +592,13 @@ def basejoin(base, url):
                else:
                        # remove last file component
                        basepath = basepath[:i+1]
+               # Interpret ../ (important because of symlinks)
+               while basepath and path[:3] == '../':
+                       path = path[3:]
+                       i = string.rfind(basepath, '/')
+                       if i > 0:
+                               basepath = basepath[:i-1]
+                       
                path = basepath + path
        if type and host: return type + '://' + host + path
        elif type: return type + ':' + path