Commit 6e04c153 authored by Facundo Batista's avatar Facundo Batista

Issue 2464. Supports a malformation in the URL received

in a redirect.
parent 5cd8ba18
...@@ -100,7 +100,7 @@ from urllib.error import URLError, HTTPError, ContentTooShortError ...@@ -100,7 +100,7 @@ from urllib.error import URLError, HTTPError, ContentTooShortError
from urllib.parse import ( from urllib.parse import (
urlparse, urlsplit, urljoin, unwrap, quote, unquote, urlparse, urlsplit, urljoin, unwrap, quote, unquote,
splittype, splithost, splitport, splituser, splitpasswd, splittype, splithost, splitport, splituser, splitpasswd,
splitattr, splitquery, splitvalue, to_bytes) splitattr, splitquery, splitvalue, to_bytes, urlunparse)
from urllib.response import addinfourl, addclosehook from urllib.response import addinfourl, addclosehook
# check for SSL # check for SSL
...@@ -535,6 +535,14 @@ class HTTPRedirectHandler(BaseHandler): ...@@ -535,6 +535,14 @@ class HTTPRedirectHandler(BaseHandler):
newurl = headers["uri"] newurl = headers["uri"]
else: else:
return return
# fix a possible malformed URL
urlparts = urlparse(newurl)
if not urlparts.path:
urlparts = list(urlparts)
urlparts[2] = "/"
newurl = urlunparse(urlparts)
newurl = urljoin(req.get_full_url(), newurl) newurl = urljoin(req.get_full_url(), newurl)
# XXX Probably want to forget about the state of the current # XXX Probably want to forget about the state of the current
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment