浏览代码

[utils] Always decode Location header

escape_url is broken for bytes-like objects
Yen Chi Hsuan 9 年之前
父节点
当前提交
0ea590076f
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      youtube_dl/utils.py

+ 2 - 0
youtube_dl/utils.py

@@ -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
                 # As of RFC 2616 default charset is iso-8859-1 that is respected by python 3
                 if sys.version_info >= (3, 0):
                 if sys.version_info >= (3, 0):
                     location = location.encode('iso-8859-1').decode('utf-8')
                     location = location.encode('iso-8859-1').decode('utf-8')
+                else:
+                    location = location.decode('utf-8')
                 location_escaped = escape_url(location)
                 location_escaped = escape_url(location)
                 if location != location_escaped:
                 if location != location_escaped:
                     del resp.headers['Location']
                     del resp.headers['Location']