diff options
author | dirkf <fieldhouse@gmx.net> | 2023-06-17 15:43:10 +0100 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2023-06-17 15:46:12 +0100 |
commit | d6433cbb2c4440056a38846e35bb5a3efa9bcac2 (patch) | |
tree | 1a3a03b57f2c0fdb021e2269b32fb9cdfc3af3b5 | |
parent | ff75c300f52321dc7322e28d1df153cf0ea65a6d (diff) |
[jsinterp] Don't find unrelated objects
-rw-r--r-- | youtube_dl/jsinterp.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index c18c4fef1..00f219440 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -941,15 +941,15 @@ class JSInterpreter(object): _FUNC_NAME_RE = r'''(?:[a-zA-Z$0-9]+|"[a-zA-Z$0-9]+"|'[a-zA-Z$0-9]+')''' obj = {} obj_m = re.search( - r'''(?x) - (?<!this\.)%s\s*=\s*{\s* - (?P<fields>(%s\s*:\s*function\s*\(.*?\)\s*{.*?}(?:,\s*)?)*) - }\s*; - ''' % (re.escape(objname), _FUNC_NAME_RE), + r'''(?xs) + (?:{0}\s*\.\s*{1}|{1}\s*=\s*\{{\s* + (?P<fields>({2}\s*:\s*function\s*\(.*?\)\s*\{{.*?}}(?:,\s*)?)*) + }}\s*); + '''.format(_NAME_RE, re.escape(objname), _FUNC_NAME_RE), self.code) - if not obj_m: + fields = obj_m and obj_m.group('fields') + if fields is None: raise self.Exception('Could not find object ' + objname) - fields = obj_m.group('fields') # Currently, it only supports function definitions fields_m = re.finditer( r'''(?x) |