From cc17865bc4c9bbc089362638237e31e9a83ffd31 Mon Sep 17 00:00:00 2001 From: sulyi Date: Mon, 21 Nov 2016 11:33:57 +0100 Subject: [PATCH] [jsinterp] Adding in_string state to extract_arguments --- youtube_dl/jsinterp.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index 72b63ca43..e12238911 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -252,15 +252,20 @@ class JSInterpreter(object): # XXX: context-free! close_pos = open_pos = call_m.end() counter = 1 + in_string = '' while counter > 0: if close_pos > len(self.code): raise ExtractorError('Runaway argument found of JS call %r' % call) c = self.code[close_pos] close_pos += 1 - if c == '(': + if c == '(' and not in_string: counter += 1 - elif c == ')': + elif c == ')' and not in_string: counter -= 1 + elif in_string and c == in_string: + in_string = '' + elif c in ['"', '\'']: + in_string = c else: return self.code[open_pos:close_pos - 1]