]> granicus.if.org Git - python/commitdiff
Merged revisions 87329 via svnmerge from
authorSenthil Kumaran <orsenthil@gmail.com>
Fri, 17 Dec 2010 04:56:02 +0000 (04:56 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Fri, 17 Dec 2010 04:56:02 +0000 (04:56 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87329 | senthil.kumaran | 2010-12-17 12:48:45 +0800 (Fri, 17 Dec 2010) | 3 lines

  Fix Issue9721 - urljoin behavior when the relative url starts with ';'
........

Lib/test/test_urlparse.py
Lib/urlparse.py
Misc/NEWS

index 82440176f42beddedffe888123ebee84d2e51021..c5764c59ca98104b58614ca19f306c77ba37dac4 100644 (file)
@@ -295,6 +295,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')
index 4ac986733164ca411b1115fcf06b9aba1b258002..a019a7b7a49e02e0e8d9f44d650d4047ae325dd8 100644 (file)
@@ -256,14 +256,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,
index 550479696b08925184dab97ad61f714d5a697552..aca1fbb99e7ab38dbb8383e1dae23f73c9aa8b8f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -21,6 +21,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.