From e612be59263f9771f89c79a89843872ae1b8f667 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 3 Dec 1997 22:38:56 +0000 Subject: [PATCH] Patch my Marc Lemburg to fix urljoin("/a", "..") and urljoin("/a", "..#1"). --- Lib/urlparse.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/urlparse.py b/Lib/urlparse.py index 22a5fd0e901..560028df94c 100644 --- a/Lib/urlparse.py +++ b/Lib/urlparse.py @@ -151,7 +151,9 @@ def urljoin(base, url, allow_framents = 1): i = i+1 else: break - if len(segments) >= 2 and segments[-1] == '..': + if len(segments) == 2 and segments[1] == '..' and segments[0] == '': + segments[-1] = '' + elif len(segments) >= 2 and segments[-1] == '..': segments[-2:] = [''] return urlunparse((scheme, netloc, joinfields(segments, '/'), params, query, fragment))