1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-12-09 17:55:28 +00:00

Fix id sanitization in filenames

Closes #415
This commit is contained in:
pukkandan
2021-06-17 02:15:57 +05:30
parent e858a9d6d3
commit 9fea350f0d
3 changed files with 17 additions and 6 deletions

View File

@@ -934,7 +934,7 @@ class YoutubeDL(object):
fmt = outer_mobj.group('format')
mobj = re.match(INTERNAL_FORMAT_RE, key)
if mobj is None:
value, default = None, na
value, default, mobj = None, na, {'fields': ''}
else:
mobj = mobj.groupdict()
default = mobj['default'] if mobj['default'] is not None else na
@@ -944,7 +944,6 @@ class YoutubeDL(object):
fmt = '0{:d}d'.format(field_size_compat_map[key])
value = default if value is None else value
key += '\0%s' % fmt
if fmt == 'c':
value = compat_str(value)
@@ -962,7 +961,8 @@ class YoutubeDL(object):
# So we convert it to repr first
value, fmt = repr(value), '%ss' % fmt[:-1]
if fmt[-1] in 'csr':
value = sanitize(key, value)
value = sanitize(mobj['fields'].split('.')[-1], value)
key += '\0%s' % fmt
TMPL_DICT[key] = value
return '%({key}){fmt}'.format(key=key, fmt=fmt)

View File

@@ -6241,6 +6241,8 @@ def traverse_obj(obj, keys, *, casesense=True, is_user_input=False, traverse_str
if is_user_input:
key = (int_or_none(key) if ':' not in key
else slice(*map(int_or_none, key.split(':'))))
if key is None:
return None
if not isinstance(obj, (list, tuple)):
if traverse_string:
obj = compat_str(obj)