From e2645826be0449842dcc812e31541c5254c69e05 Mon Sep 17 00:00:00 2001 From: Chris Dary Date: Tue, 28 Feb 2012 12:08:37 -0500 Subject: [PATCH] Decode URL to utf-8 before joining. To avoid UnicodeDecodeError's like on http://blip.fm/~1abvfu --- requests/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requests/models.py b/requests/models.py index 8368c9f..aea7723 100644 --- a/requests/models.py +++ b/requests/models.py @@ -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 -- 2.7.4