8000 Fix Issue9721 - urljoin behavior when the relative url starts with ';' · python/cpython@dca5b86 · GitHub
[go: up one dir, main page]

Skip to content

Commit dca5b86

Browse files
committed
Fix Issue9721 - urljoin behavior when the relative url starts with ';'
1 parent b25a791 commit dca5b86

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Lib/test/test_urlparse.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ def test_RFC3986(self):
327327
#self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser
328328
self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') #relaxed parser
329329

330+
# Test for issue9721
331+
self.checkJoin('http://a/b/c/de', ';x','http://a/b/c/;x')
332+
330333
def test_urljoins(self):
331334
self.checkJoin(SIMPLE_BASE, 'g:h','g:h')
332335
self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g')

Lib/urllib/parse.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,9 @@ def urljoin(base, url, allow_fragments=True):
411411
if path[:1] == '/':
412412
return _coerce_result(urlunparse((scheme, netloc, path,
413413
params, query, fragment)))
414-
if not path:
414+
if not path and not params:
415415
path = bpath
416-
if not params:
417-
params = bparams
418-
else:
419-
path = path[:-1]
420-
return _coerce_result(urlunparse((scheme, netloc, path,
421-
params, query, fragment)))
416+
params = bparams
422417
if not query:
423418
query = bquery
424419
return _coerce_result(urlunparse((scheme, netloc, path,

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Core and Builtins
1919

2020
Library
2121
-------
22+
- Issue #9721: Fix the behavior of urljoin when the relative url starts with a
23+
';' character. Patch by Wes Chow.
2224

2325
- Issue #10714: Limit length of incoming request in http.server to 65536 bytes
2426
for security reasons. Initial patch by Ross Lagerwall.

0 commit comments

Comments
 (0)
0