diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index 17184d5b0d..7b01bc39cd 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -443,6 +443,9 @@ class TestJSInterpreter(unittest.TestCase): self._test('function f(){return "012345678".slice(-1, 1)}', '') self._test('function f(){return "012345678".slice(-3, -1)}', '67') + def test_splice(self): + self._test('function f(){var T = ["0", "1", "2"]; T["splice"](2, 1, "0")[0]; return T }', ['0', '1', '0']) + def test_js_number_to_string(self): for test, radix, expected in [ (0, None, '0'), diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py index c69d099350..f2f98135be 100644 --- a/yt_dlp/jsinterp.py +++ b/yt_dlp/jsinterp.py @@ -611,10 +611,16 @@ class JSInterpreter: =(?!=)(?P.*)$ )|(?P (?!if|return|true|false|null|undefined|NaN)(?P{_NAME_RE})$ + )|(?P + (?P{_NAME_RE})(?: + (?P\?)?\.(?P[^(]+)| + \[(?P[^[\]]+ + (?:\[[^[\]]+ + (?:\[[^\]]+\])?\] + )?) + \])\s* )|(?P (?P{_NAME_RE})\[(?P.+)\]$ - )|(?P - (?P{_NAME_RE})(?:(?P\?)?\.(?P[^(]+)|\[(?P[^\[\]]+(?:\[[^\[\]]+(?:\[[^\]]+\])?\])?)\])\s* )|(?P (?P{_NAME_RE})\((?P.*)\)$ )''', expr)