[utils] Always decode Location header
authorYen Chi Hsuan <yan12125@gmail.com>
Thu, 26 May 2016 09:22:40 +0000 (17:22 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Thu, 2 Jun 2016 07:00:49 +0000 (15:00 +0800)
escape_url is broken for bytes-like objects

youtube_dl/utils.py

index cfb2d1bf5c03c59c94d777acbc8729e6b7de6556..6ab1747b3cc058f1e3e22a3b5c5b8967488d5090 100644 (file)
@@ -861,6 +861,8 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
                 # As of RFC 2616 default charset is iso-8859-1 that is respected by python 3
                 if sys.version_info >= (3, 0):
                     location = location.encode('iso-8859-1').decode('utf-8')
+                else:
+                    location = location.decode('utf-8')
                 location_escaped = escape_url(location)
                 if location != location_escaped:
                     del resp.headers['Location']