From: Sergey M․ Date: Thu, 18 May 2017 15:57:38 +0000 (+0700) Subject: [jsinterp] Fix typo and cleanup regexes (closes #13134) X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=0e2d626ddd2c0c4a8e369026812c7092f5d17de2;p=youtube-dl [jsinterp] Fix typo and cleanup regexes (closes #13134) --- diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index 038910049..7bda59610 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -214,15 +214,18 @@ 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'(?(%s\s*:\s*function\(.*?\)\s*\{.*?\}(?:,\s*)?)*)' + - r'\}\s*;' % _FUNC_NAME_RE, + r'''(?x) + (?(%s\s*:\s*function\s*\(.*?\)\s*{.*?}(?:,\s*)?)*) + }\s*; + ''' % (re.escape(objname), _FUNC_NAME_RE), self.code) fields = obj_m.group('fields') # Currently, it only supports function definitions fields_m = re.finditer( - r'(?P%s)\s*:\s*function' - r'\((?P[a-z,]+)\){(?P[^}]+)}' % _FUNC_NAME_RE, + r'''(?x) + (?P%s)\s*:\s*function\s*\((?P[a-z,]+)\){(?P[^}]+)} + ''' % _FUNC_NAME_RE, fields) for f in fields_m: argnames = f.group('args').split(',')