1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-25 11:41:52 +00:00

[jsinterp] Don't find unrelated objects

This commit is contained in:
dirkf 2023-06-17 15:43:10 +01:00
parent ff75c300f5
commit d6433cbb2c

View file

@ -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]+')''' _FUNC_NAME_RE = r'''(?:[a-zA-Z$0-9]+|"[a-zA-Z$0-9]+"|'[a-zA-Z$0-9]+')'''
obj = {} obj = {}
obj_m = re.search( obj_m = re.search(
r'''(?x) r'''(?xs)
(?<!this\.)%s\s*=\s*{\s* (?:{0}\s*\.\s*{1}|{1}\s*=\s*\{{\s*
(?P<fields>(%s\s*:\s*function\s*\(.*?\)\s*{.*?}(?:,\s*)?)*) (?P<fields>({2}\s*:\s*function\s*\(.*?\)\s*\{{.*?}}(?:,\s*)?)*)
}\s*; }}\s*);
''' % (re.escape(objname), _FUNC_NAME_RE), '''.format(_NAME_RE, re.escape(objname), _FUNC_NAME_RE),
self.code) 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) raise self.Exception('Could not find object ' + objname)
fields = obj_m.group('fields')
# Currently, it only supports function definitions # Currently, it only supports function definitions
fields_m = re.finditer( fields_m = re.finditer(
r'''(?x) r'''(?x)