From 06d20084911858b2fcebeb49fce72a2026cbd73c Mon Sep 17 00:00:00 2001 From: sepro Date: Wed, 26 Mar 2025 18:09:16 +0100 Subject: [PATCH] [jsinterp] Improve nested attribute support --- test/test_jsinterp.py | 2 ++ yt_dlp/jsinterp.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index d3076298cc..17184d5b0d 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -403,6 +403,8 @@ class TestJSInterpreter(unittest.TestCase): test_result = list('test') tests = [ 'function f(a, b){return a.split(b)}', + 'function f(a, b){return a["split"](b)}', + 'function f(a, b){let x = ["split"]; return a[x[0]](b)}', 'function f(a, b){return String.prototype.split.call(a, b)}', 'function f(a, b){return String.prototype.split.apply(a, [b])}', ] diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py index d46b78f64f..5e452aa674 100644 --- a/yt_dlp/jsinterp.py +++ b/yt_dlp/jsinterp.py @@ -614,7 +614,7 @@ class JSInterpreter: )|(?P (?P{_NAME_RE})\[(?P.+)\]$ )|(?P - (?P{_NAME_RE})(?:(?P\?)?\.(?P[^(]+)|\[(?P[^\]]+)\])\s* + (?P{_NAME_RE})(?:(?P\?)?\.(?P[^(]+)|\[(?P[^\[\]]+(?:\[[^\[\]]+(?:\[[^\]]+\])?\])?)\])\s* )|(?P (?P{_NAME_RE})\((?P.*)\)$ )''', expr)