diff options
author | Guido van Rossum <guido@python.org> | 1997-04-11 19:09:51 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-04-11 19:09:51 (GMT) |
commit | 54a1d0bc699ea0cbe4fbe79dfe3ddcd427ab807e (patch) | |
tree | 14057af04edd0978eeac009600e7947cc33654e7 /Lib/urllib.py | |
parent | c511aee0e37d82639dcd4f9b3d0446b8a05d8077 (diff) | |
download | cpython-54a1d0bc699ea0cbe4fbe79dfe3ddcd427ab807e.zip cpython-54a1d0bc699ea0cbe4fbe79dfe3ddcd427ab807e.tar.gz cpython-54a1d0bc699ea0cbe4fbe79dfe3ddcd427ab807e.tar.bz2 |
(Jack+Guido:) interpret ../ in basejoin() according to RFC1808.
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r-- | Lib/urllib.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index e57311b..a8a579b 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -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 |