mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-12-07 00:35:18 +00:00
[jsinterp] Fix escape in regex
This commit is contained in:
@@ -2702,7 +2702,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
|
||||
def _extract_n_function_code(self, video_id, player_url):
|
||||
player_id = self._extract_player_info(player_url)
|
||||
func_code = self.cache.load('youtube-nsig', player_id, min_ver='2022.08.19.2')
|
||||
func_code = self.cache.load('youtube-nsig', player_id, min_ver='2022.09.1')
|
||||
jscode = func_code or self._load_player(video_id, player_url)
|
||||
jsi = JSInterpreter(jscode)
|
||||
|
||||
|
||||
@@ -245,11 +245,12 @@ class JSInterpreter:
|
||||
counters[_MATCHING_PARENS[char]] += 1
|
||||
elif not in_quote and char in counters:
|
||||
counters[char] -= 1
|
||||
elif not escaping and char in _QUOTES and in_quote in (char, None):
|
||||
if in_quote or after_op or char != '/':
|
||||
in_quote = None if in_quote and not in_regex_char_group else char
|
||||
elif in_quote == '/' and char in '[]':
|
||||
in_regex_char_group = char == '['
|
||||
elif not escaping:
|
||||
if char in _QUOTES and in_quote in (char, None):
|
||||
if in_quote or after_op or char != '/':
|
||||
in_quote = None if in_quote and not in_regex_char_group else char
|
||||
elif in_quote == '/' and char in '[]':
|
||||
in_regex_char_group = char == '['
|
||||
escaping = not escaping and in_quote and char == '\\'
|
||||
after_op = not in_quote and char in OP_CHARS or (char.isspace() and after_op)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user