mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
Fix by John Nagle.
This commit is contained in:
parent
3001c5463e
commit
c6a04c2629
3 changed files with 13 additions and 7 deletions
|
@ -316,6 +316,11 @@ class UrlParseTestCase(unittest.TestCase):
|
||||||
self.assertEqual(type(p.hostname), type(uri))
|
self.assertEqual(type(p.hostname), type(uri))
|
||||||
self.assertEqual(type(p.path), type(uri))
|
self.assertEqual(type(p.path), type(uri))
|
||||||
|
|
||||||
|
def test_noslash(self):
|
||||||
|
# Issue 1637: http://foo.com?query is legal
|
||||||
|
self.assertEqual(urlparse.urlparse("http://example.com?blahblah=/foo"),
|
||||||
|
('http', 'example.com', '', '', 'blahblah=/foo', ''))
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
test_support.run_unittest(UrlParseTestCase)
|
test_support.run_unittest(UrlParseTestCase)
|
||||||
|
|
||||||
|
|
|
@ -169,13 +169,12 @@ def _splitparams(url):
|
||||||
return url[:i], url[i+1:]
|
return url[:i], url[i+1:]
|
||||||
|
|
||||||
def _splitnetloc(url, start=0):
|
def _splitnetloc(url, start=0):
|
||||||
for c in '/?#': # the order is important!
|
delim = len(url) # position of end of domain part of url, default is end
|
||||||
delim = url.find(c, start)
|
for c in '/?#': # look for delimiters; the order is NOT important
|
||||||
if delim >= 0:
|
wdelim = url.find(c, start) # find first of this delim
|
||||||
break
|
if wdelim >= 0: # if found
|
||||||
else:
|
delim = min(delim, wdelim) # use earliest delim position
|
||||||
delim = len(url)
|
return url[start:delim], url[delim:] # return (domain, rest)
|
||||||
return url[start:delim], url[delim:]
|
|
||||||
|
|
||||||
def urlsplit(url, scheme='', allow_fragments=True):
|
def urlsplit(url, scheme='', allow_fragments=True):
|
||||||
"""Parse a URL into 5 components:
|
"""Parse a URL into 5 components:
|
||||||
|
|
|
@ -342,6 +342,8 @@ Core and builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Patch #1637: fix urlparse for URLs like 'http://x.com?arg=/foo'.
|
||||||
|
|
||||||
- Patch #1698: allow '@' in username parsed by urlparse.py.
|
- Patch #1698: allow '@' in username parsed by urlparse.py.
|
||||||
|
|
||||||
- Issue #1735: TarFile.extractall() now correctly sets directory permissions
|
- Issue #1735: TarFile.extractall() now correctly sets directory permissions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue