mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-27 17:08:32 +00:00
[devalue] guard against Python negative indexing
Authored by: bashonly
This commit is contained in:
parent
363c68d3ed
commit
9d00bd01ce
@ -39,6 +39,8 @@ def parse_iter(parsed: typing.Any, /, *, revivers: dict[str, collections.abc.Cal
|
|||||||
-5: -math.inf,
|
-5: -math.inf,
|
||||||
-6: -0.0,
|
-6: -0.0,
|
||||||
}
|
}
|
||||||
|
lowest_valid_index = min(resolved.keys())
|
||||||
|
|
||||||
if isinstance(parsed, int):
|
if isinstance(parsed, int):
|
||||||
if parsed == -2:
|
if parsed == -2:
|
||||||
raise ValueError('invalid input')
|
raise ValueError('invalid input')
|
||||||
@ -66,6 +68,10 @@ def parse_iter(parsed: typing.Any, /, *, revivers: dict[str, collections.abc.Cal
|
|||||||
target[index] = resolved[source]
|
target[index] = resolved[source]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if source < lowest_valid_index:
|
||||||
|
yield IndexError(f'invalid index: {source!r}')
|
||||||
|
continue
|
||||||
|
|
||||||
value = parsed[source]
|
value = parsed[source]
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
if value and isinstance(value[0], str):
|
if value and isinstance(value[0], str):
|
||||||
|
Loading…
Reference in New Issue
Block a user