]> granicus.if.org Git - python/commitdiff
Merged revisions 87329 via svnmerge from
authorSenthil Kumaran <orsenthil@gmail.com>
Fri, 17 Dec 2010 04:54:43 +0000 (04:54 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Fri, 17 Dec 2010 04:54:43 +0000 (04:54 +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/urllib/parse.py
Misc/NEWS

index ec2df3c8b7a3ec7c4fd277d5f4ffbf246181c052..1c6c501d673a1a44c268240c0fa8738ea9967c65 100644 (file)
@@ -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')
index cfd47f9d92b756ffc259e4b2f0c1ec4cdfd4e5df..e8e9cc7b9274b23285dc10032840dc2da301b8f9 100644 (file)
@@ -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,
index 2b09d5fc6768421202ed8380a1cf287707275e6b..a49b34488c007c0628e7a5e78f6be68d7427b039 100644 (file)
--- 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.