]> granicus.if.org Git - python/commitdiff
Forgot to backport the rest of #1637.
authorGuido van Rossum <guido@python.org>
Sun, 6 Jan 2008 02:40:07 +0000 (02:40 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 6 Jan 2008 02:40:07 +0000 (02:40 +0000)
Lib/urlparse.py
Misc/NEWS

index ad5d75f681d93921ef9ab15dddb7e033045662b5..4bc577c6fc44b41cd387b37ca3c9f72777f49bd1 100644 (file)
@@ -169,13 +169,12 @@ def _splitparams(url):
     return url[:i], url[i+1:]
 
 def _splitnetloc(url, start=0):
-    for c in '/?#': # the order is important!
-        delim = url.find(c, start)
-        if delim >= 0:
-            break
-    else:
-        delim = len(url)
-    return url[start:delim], url[delim:]
+    delim = len(url)   # position of end of domain part of url, default is end
+    for c in '/?#':    # look for delimiters; the order is NOT important
+        wdelim = url.find(c, start)        # find first of this delim
+        if wdelim >= 0:                    # if found
+            delim = min(delim, wdelim)     # use earliest delim position
+    return url[start:delim], url[delim:]   # return (domain, rest)
 
 def urlsplit(url, scheme='', allow_fragments=True):
     """Parse a URL into 5 components:
index 299b3af29f2168edcea979aaa54c87bfff31ebcd..7f3f62845341293779533755a4cb04c1c22356d9 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -53,6 +53,8 @@ Core and builtins
 Library
 -------
 
+- Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
+
 - Issue #1735: TarFile.extractall() now correctly sets directory permissions
   and times.