Skip to content

Commit 54a1d0b

Browse files
committed
(Jack+Guido:) interpret ../ in basejoin() according to RFC1808.
1 parent c511aee commit 54a1d0b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/urllib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,13 @@ def basejoin(base, url):
592592
else:
593593
# remove last file component
594594
basepath = basepath[:i+1]
595+
# Interpret ../ (important because of symlinks)
596+
while basepath and path[:3] == '../':
597+
path = path[3:]
598+
i = string.rfind(basepath, '/')
599+
if i > 0:
600+
basepath = basepath[:i-1]
601+
595602
path = basepath + path
596603
if type and host: return type + '://' + host + path
597604
elif type: return type + ':' + path

0 commit comments

Comments
 (0)