summaryrefslogtreecommitdiffstats
path: root/Lib/urlparse.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2008-01-05 22:19:06 (GMT)
committerGuido van Rossum <guido@python.org>2008-01-05 22:19:06 (GMT)
commitc6a04c2629c43b104b81e8584be21aa1b8bae77f (patch)
tree4eed51ce7065079de67ed04f4674cd58240c5b0d /Lib/urlparse.py
parent3001c5463ecfb8fe17b434733b1bfc399b89e80e (diff)
downloadcpython-c6a04c2629c43b104b81e8584be21aa1b8bae77f.zip
cpython-c6a04c2629c43b104b81e8584be21aa1b8bae77f.tar.gz
cpython-c6a04c2629c43b104b81e8584be21aa1b8bae77f.tar.bz2
Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
Fix by John Nagle.
Diffstat (limited to 'Lib/urlparse.py')
-rw-r--r--Lib/urlparse.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index 4bf0af3..7a2e6ce 100644
--- a/Lib/urlparse.py
+++ b/Lib/urlparse.py
@@ -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: