mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-08-20 13:24:16 -07:00
parent
96f87aaa3b
commit
e1eae16b56
2 changed files with 29 additions and 9 deletions
|
@ -240,21 +240,26 @@ class JSInterpreter(object):
|
|||
switch_val, remaining = self._separate_at_paren(expr[m.end() - 1:], ')')
|
||||
switch_val = self.interpret_expression(switch_val, local_vars, allow_recursion)
|
||||
body, expr = self._separate_at_paren(remaining, '}')
|
||||
body, default = body.split('default:') if 'default:' in body else (body, None)
|
||||
items = body.split('case ')[1:]
|
||||
if default:
|
||||
items.append('default:%s' % (default, ))
|
||||
matched = False
|
||||
for item in items:
|
||||
case, stmt = [i.strip() for i in self._separate(item, ':', 1)]
|
||||
matched = matched or case == 'default' or switch_val == self.interpret_expression(case, local_vars, allow_recursion)
|
||||
if matched:
|
||||
items = body.replace('default:', 'case default:').split('case ')[1:]
|
||||
for default in (False, True):
|
||||
matched = False
|
||||
for item in items:
|
||||
case, stmt = [i.strip() for i in self._separate(item, ':', 1)]
|
||||
if default:
|
||||
matched = matched or case == 'default'
|
||||
elif not matched:
|
||||
matched = (case != 'default'
|
||||
and switch_val == self.interpret_expression(case, local_vars, allow_recursion))
|
||||
if not matched:
|
||||
continue
|
||||
try:
|
||||
ret, should_abort = self.interpret_statement(stmt, local_vars, allow_recursion - 1)
|
||||
if should_abort:
|
||||
return ret
|
||||
except JS_Break:
|
||||
break
|
||||
if matched:
|
||||
break
|
||||
return self.interpret_statement(expr, local_vars, allow_recursion - 1)[0]
|
||||
|
||||
# Comma separated statements
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue