diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2016-03-23 22:24:52 +0800 |
---|---|---|
committer | Yen Chi Hsuan <yan12125@gmail.com> | 2016-03-23 22:24:52 +0800 |
commit | efbed08dc20c530fe428256e4dcbea4dc4423d0d (patch) | |
tree | 836f73a2f8b9f8b2f528619ec13374e42decce32 /youtube_dl | |
parent | 7da2c87119db8beda1bdc979fad38c08fc1252e9 (diff) |
[utils] Encode hostnames before passing to urllib
With IDN (Internationalized Domain Name) and a proxy, non-ascii URLs
are passed down to urllib/urllib2, causing UnicodeEncodeError
Fixes #8890
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/utils.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 067b8a184..03bb7782f 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1746,6 +1746,7 @@ def escape_url(url): """Escape URL as suggested by RFC 3986""" url_parsed = compat_urllib_parse_urlparse(url) return url_parsed._replace( + netloc=url_parsed.netloc.encode('idna').decode('ascii'), path=escape_rfc3986(url_parsed.path), params=escape_rfc3986(url_parsed.params), query=escape_rfc3986(url_parsed.query), |