From: Facundo Batista Date: Sun, 17 Aug 2008 03:38:39 +0000 (+0000) Subject: Issue 2464. Supports a malformation in the URL received X-Git-Tag: v2.6b3~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94f243aa41286fa6f3733c21d7936222e7f6c251;p=thirdparty%2FPython%2Fcpython.git Issue 2464. Supports a malformation in the URL received in a redirect. --- diff --git a/Lib/urllib2.py b/Lib/urllib2.py index 121685c0a8da..7b209d4c63ef 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -560,6 +560,14 @@ class HTTPRedirectHandler(BaseHandler): newurl = headers.getheaders('uri')[0] else: return + + # fix a possible malformed URL + urlparts = urlparse.urlparse(newurl) + if not urlparts.path: + urlparts = list(urlparts) + urlparts[2] = "/" + newurl = urlparse.urlunparse(urlparts) + newurl = urlparse.urljoin(req.get_full_url(), newurl) # XXX Probably want to forget about the state of the current diff --git a/Misc/NEWS b/Misc/NEWS index 7736ca7c03ea..08ee9f9d252c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -48,6 +48,9 @@ Core and Builtins Library ------- +- Issue 2464. urllib2 now supports a malformation in the URL received + in a redirect. + - Silence the DeprecationWarning raised when importing mimetools in BaseHTTPServer, cgi (and rfc822), httplib.