From d17ebdba4a4443a523c0344440d37d472ed82b5a Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Mon, 22 Nov 2010 04:53:57 +0000 Subject: Merged revisions 86676 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86676 | senthil.kumaran | 2010-11-22 12:48:26 +0800 (Mon, 22 Nov 2010) | 4 lines Fix Issue4493 - urllib2 adds '/' to the path component of url, when it does not starts with one. This behavior is exhibited by browser and other clients. ........ --- Lib/urllib/parse.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Lib/urllib/parse.py') diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index b437d6f43ba..cfd47f9d92b 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -688,7 +688,12 @@ def splithost(url): _hostprog = re.compile('^//([^/?]*)(.*)$') match = _hostprog.match(url) - if match: return match.group(1, 2) + if match: + host_port = match.group(1) + path = match.group(2) + if path and not path.startswith('/'): + path = '/' + path + return host_port, path return None, url _userprog = None -- cgit v1.2.3