[Python-checkins] r87329 - in python/branches/py3k: Lib/test/test_urlparse.py Lib/urllib/parse.py Misc/NEWS

senthil.kumaran python-checkins at python.org
Fri Dec 17 05:48:45 CET 2010


Author: senthil.kumaran
Date: Fri Dec 17 05:48:45 2010
New Revision: 87329

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



Modified:
   python/branches/py3k/Lib/test/test_urlparse.py
   python/branches/py3k/Lib/urllib/parse.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/test/test_urlparse.py
==============================================================================
--- python/branches/py3k/Lib/test/test_urlparse.py	(original)
+++ python/branches/py3k/Lib/test/test_urlparse.py	Fri Dec 17 05:48:45 2010
@@ -327,6 +327,9 @@
         #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')

Modified: python/branches/py3k/Lib/urllib/parse.py
==============================================================================
--- python/branches/py3k/Lib/urllib/parse.py	(original)
+++ python/branches/py3k/Lib/urllib/parse.py	Fri Dec 17 05:48:45 2010
@@ -411,14 +411,9 @@
     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,

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Dec 17 05:48:45 2010
@@ -19,6 +19,8 @@
 
 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.


More information about the Python-checkins mailing list