From b44cd29851fdc2fadb283adb59a074f89a27ba7e Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 8 Dec 2022 22:42:49 +0530 Subject: [PATCH] [jsinterp] Escape regex that looks like nested set Closes #5749 --- yt_dlp/jsinterp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py index e25997129d..3f7d659acf 100644 --- a/yt_dlp/jsinterp.py +++ b/yt_dlp/jsinterp.py @@ -343,7 +343,8 @@ def interpret_statement(self, stmt, local_vars, allow_recursion=100): inner, outer = self._separate(expr, expr[0], 1) if expr[0] == '/': flags, outer = self._regex_flags(outer) - inner = re.compile(inner[1:], flags=flags) + # Avoid https://github.com/python/cpython/issues/74534 + inner = re.compile(inner[1:].replace('[[', r'[\['), flags=flags) else: inner = json.loads(js_to_json(f'{inner}{expr[0]}', strict=True)) if not outer: