Decode URL to utf-8 before joining.
authorChris Dary <umbrae@gmail.com>
Tue, 28 Feb 2012 17:08:37 +0000 (12:08 -0500)
committerChris Dary <umbrae@gmail.com>
Tue, 28 Feb 2012 17:08:37 +0000 (12:08 -0500)
To avoid UnicodeDecodeError's like on http://blip.fm/~1abvfu

requests/models.py

index 8368c9fb4235e56e03392afd356a4e0942b8cec7..aea7723754e8cfd08fe55ce7544828f81e69ce00 100644 (file)
@@ -227,6 +227,8 @@ class Request(object):
                 # Facilitate non-RFC2616-compliant 'location' headers
                 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
                 if not urlparse(url).netloc:
+                    if not isinstance(url, unicode):
+                        url = url.decode('utf-8', 'ignore')
                     url = urljoin(r.url, url)
 
                 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4