summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-08-17 03:38:39 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-08-17 03:38:39 (GMT)
commit94f243aa41286fa6f3733c21d7936222e7f6c251 (patch)
tree4ad5bbc02b78d66711c59cd81aedf9990fe3f5a9 /Lib
parent25f2d89f324c1456c4bf9b4292d3bb9c2ad6293d (diff)
downloadcpython-94f243aa41286fa6f3733c21d7936222e7f6c251.zip
cpython-94f243aa41286fa6f3733c21d7936222e7f6c251.tar.gz
cpython-94f243aa41286fa6f3733c21d7936222e7f6c251.tar.bz2
Issue 2464. Supports a malformation in the URL received
in a redirect.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/urllib2.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index 121685c..7b209d4 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