Sanitise format_id to match format selection

Valid characters in format selection expression RHS are [a-zA-Z0-9_.-]
This commit is contained in:
dirkf 2021-08-01 20:58:45 +01:00 committed by df
parent a803582717
commit 25903f82c8

View File

@ -1597,7 +1597,9 @@ class YoutubeDL(object):
format['format_id'] = compat_str(i) format['format_id'] = compat_str(i)
else: else:
# Sanitize format_id from characters used in format selector expression # 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'] format_id = format['format_id']
if format_id not in formats_dict: if format_id not in formats_dict:
formats_dict[format_id] = [] formats_dict[format_id] = []