1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-25 18:27:42 +00:00

[YoutubeDL] Sanitize byte string format URLs (#13951)

This commit is contained in:
Sergey M․ 2017-08-17 23:59:12 +07:00
parent 5551d7714d
commit a5ac0c4755
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -1483,12 +1483,14 @@ class YoutubeDL(object):
def is_wellformed(f):
url = f.get('url')
valid_url = url and isinstance(url, compat_str)
if not valid_url:
if not url:
self.report_warning(
'"url" field is missing or empty - skipping format, '
'there is an error in extractor')
return valid_url
return False
if isinstance(url, bytes):
sanitize_string_field(f, 'url')
return True
# Filter out malformed formats for better extraction robustness
formats = list(filter(is_wellformed, formats))