facundo.batista
2008-08-17 03:36:03 UTC
Author: facundo.batista
Date: Sun Aug 17 05:36:03 2008
New Revision: 65740
Log:
Issue 2464. Supports a malformation in the URL received
in a redirect.
Modified:
python/branches/py3k/Lib/urllib/request.py
Modified: python/branches/py3k/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k/Lib/urllib/request.py (original)
+++ python/branches/py3k/Lib/urllib/request.py Sun Aug 17 05:36:03 2008
@@ -100,7 +100,7 @@
from urllib.parse import (
urlparse, urlsplit, urljoin, unwrap, quote, unquote,
splittype, splithost, splitport, splituser, splitpasswd,
- splitattr, splitquery, splitvalue, to_bytes)
+ splitattr, splitquery, splitvalue, to_bytes, urlunparse)
from urllib.response import addinfourl, addclosehook
# check for SSL
@@ -535,6 +535,14 @@
newurl = headers["uri"]
else:
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)
# XXX Probably want to forget about the state of the current
Date: Sun Aug 17 05:36:03 2008
New Revision: 65740
Log:
Issue 2464. Supports a malformation in the URL received
in a redirect.
Modified:
python/branches/py3k/Lib/urllib/request.py
Modified: python/branches/py3k/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k/Lib/urllib/request.py (original)
+++ python/branches/py3k/Lib/urllib/request.py Sun Aug 17 05:36:03 2008
@@ -100,7 +100,7 @@
from urllib.parse import (
urlparse, urlsplit, urljoin, unwrap, quote, unquote,
splittype, splithost, splitport, splituser, splitpasswd,
- splitattr, splitquery, splitvalue, to_bytes)
+ splitattr, splitquery, splitvalue, to_bytes, urlunparse)
from urllib.response import addinfourl, addclosehook
# check for SSL
@@ -535,6 +535,14 @@
newurl = headers["uri"]
else:
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)
# XXX Probably want to forget about the state of the current