]> granicus.if.org Git - python/commitdiff
Fix Issue9721 - urljoin behavior when the relative url starts with ';'
authorSenthil Kumaran <orsenthil@gmail.com>
Fri, 17 Dec 2010 04:48:45 +0000 (04:48 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Fri, 17 Dec 2010 04:48:45 +0000 (04:48 +0000)
Lib/test/test_urlparse.py
Lib/urllib/parse.py
Misc/NEWS

index 73e4de580bf1ed00e055b50ab193bd0fb5af1a36..f9f97b110b32a4b89cdc995a76288924a7fc01f7 100644 (file)
@@ -327,6 +327,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 eedd07111305a5bd7afb63474bda5d66e1b4cc1b..42f81936828d4cb9507fc8c3a8098ab8eb7d6743 100644 (file)
@@ -411,14 +411,9 @@ def urljoin(base, url, allow_fragments=True):
     if path[:1] == '/':
         return _coerce_result(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 _coerce_result(urlunparse((scheme, netloc, path,
-                                              params, query, fragment)))
+        params = bparams
         if not query:
             query = bquery
         return _coerce_result(urlunparse((scheme, netloc, path,
index 19611dd20bce849ce09beacebac88d78cc56e8e5..1fce06c1558347c498dd4a744bd73d919eb6ed33 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,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.