1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2025-06-23 03:46:19 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
dirkf
2ac713d0e3
Merge 25903f82c8d123ec2a22ae36ee7015a694bc2420 into 3eb8d22ddb8982ca4fb56bb7a8d6517538bf14c6 2025-04-01 09:46:26 +02:00
dirkf
25903f82c8 Sanitise format_id to match format selection
Valid characters in format selection expression RHS are [a-zA-Z0-9_.-]
2021-08-01 21:16:02 +01:00

View File

@ -1762,7 +1762,9 @@ class YoutubeDL(object):
format['format_id'] = compat_str(i)
else:
# Sanitize format_id from characters used in format selector expression
format['format_id'] = re.sub(r'[\s,/+\[\]()]', '_', format['format_id'])
# In fact, replace anything that's not allowed as a value in format selection,
# or (eg) excluding a format_id can crash. See method _build_format_filter()
format['format_id'] = re.sub(r'[^a-zA-Z0-9._-]', '_', format['format_id'])
format_id = format['format_id']
if format_id not in formats_dict:
formats_dict[format_id] = []