]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #23703: Fix a regression in urljoin() introduced in 901e4e52b20a.
authorBerker Peksag <berker.peksag@gmail.com>
Wed, 15 Apr 2015 23:31:14 +0000 (02:31 +0300)
committerBerker Peksag <berker.peksag@gmail.com>
Wed, 15 Apr 2015 23:31:14 +0000 (02:31 +0300)
Patch by Demian Brecht.

Lib/test/test_urlparse.py
Lib/urllib/parse.py
Misc/NEWS

index 5a3aa3372d64ee2778e41098f48eff3df3c32caa..156ccf58cae512745ee9f68c5609ea8fb6d5ee23 100644 (file)
@@ -391,6 +391,9 @@ class UrlParseTestCase(unittest.TestCase):
         self.checkJoin('http://a/b/c/d/e/', '../../f/g', 'http://a/b/c/f/g')
         self.checkJoin('http://a/b/', '../../f/g/', 'http://a/f/g/')
 
+        # issue 23703: don't duplicate filename
+        self.checkJoin('a', 'b', 'b')
+
     def test_RFC2732(self):
         str_cases = [
             ('http://Test.python.org:5432/foo/', 'test.python.org', 5432),
index 6012d3502ab8ccaed74e796634d5d710178ef207..e3133714bfe5cc0a95cc98140b3e2f8b0e4325b3 100644 (file)
@@ -447,8 +447,7 @@ def urljoin(base, url, allow_fragments=True):
         segments = base_parts + path.split('/')
         # filter out elements that would cause redundant slashes on re-joining
         # the resolved_path
-        segments = segments[0:1] + [
-            s for s in segments[1:-1] if len(s) > 0] + segments[-1:]
+        segments[1:-1] = filter(None, segments[1:-1])
 
     resolved_path = []
 
index cd1d81e45d218637a49383db430f5fbc9a301f6d..ca7de81ad9ce58137d44dee9106fbe243defc5f8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -36,6 +36,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #23703: Fix a regression in urljoin() introduced in 901e4e52b20a.
+  Patch by Demian Brecht.
+
 - Issue #4254: Adds _curses.update_lines_cols() Patch by Arnon Yaari
 
 - Issue 19933: Provide default argument for ndigits in round. Patch by