(Jack+Guido:) interpret ../ in basejoin() according to RFC1808.

This commit is contained in:
Guido van Rossum 1997-04-11 19:09:51 +00:00
parent c511aee0e3
commit 54a1d0bc69
1 changed files with 7 additions and 0 deletions

View 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