[outtmpl] Limit changes during sanitization

Closes #2761
This commit is contained in:
pukkandan 2022-03-27 10:04:04 +05:30
parent fd2ad7cb24
commit 5c3895fff1
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
5 changed files with 30 additions and 20 deletions

View file

@ -87,6 +87,7 @@ from .utils import (
MaxDownloadsReached,
merge_headers,
network_exceptions,
NO_DEFAULT,
number_of_digits,
orderedSet,
OUTTMPL_TYPES,
@ -1150,8 +1151,10 @@ class YoutubeDL(object):
na = self.params.get('outtmpl_na_placeholder', 'NA')
def filename_sanitizer(key, value, restricted=self.params.get('restrictfilenames')):
return sanitize_filename(str(value), restricted=restricted,
is_id=re.search(r'(^|[_.])id(\.|$)', key))
return sanitize_filename(str(value), restricted=restricted, is_id=(
bool(re.search(r'(^|[_.])id(\.|$)', key))
if 'filename-sanitization' in self.params.get('compat_opts', [])
else NO_DEFAULT))
sanitizer = sanitize if callable(sanitize) else filename_sanitizer
sanitize = bool(sanitize)