summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_urlparse.py3
-rw-r--r--Lib/urllib/parse.py9
-rw-r--r--Misc/NEWS2
3 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index ec2df3c..1c6c501 100644
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -293,6 +293,9 @@ class UrlParseTestCase(unittest.TestCase):
#self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser
self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') #relaxed parser
+ # Test for issue9721
+ self.checkJoin('http://a/b/c/de', ';x','http://a/b/c/;x')
+
def test_urljoins(self):
self.checkJoin(SIMPLE_BASE, 'g:h','g:h')
self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g')
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index cfd47f9..e8e9cc7 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -249,14 +249,9 @@ def urljoin(base, url, allow_fragments=True):
if path[:1] == '/':
return urlunparse((scheme, netloc, path,
params, query, fragment))
- if not path:
+ if not path and not params:
path = bpath
- if not params:
- params = bparams
- else:
- path = path[:-1]
- return urlunparse((scheme, netloc, path,
- params, query, fragment))
+ params = bparams
if not query:
query = bquery
return urlunparse((scheme, netloc, path,
diff --git a/Misc/NEWS b/Misc/NEWS
index 2b09d5f..a49b344 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -20,6 +20,8 @@ Core and Builtins
Library
-------
+- Issue #9721: Fix the behavior of urljoin when the relative url starts with a
+ ';' character. Patch by Wes Chow.
- Issue #10714: Limit length of incoming request in http.server to 65536 bytes
for security reasons. Initial patch by Ross Lagerwall.