aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/jsinterp.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-09-01 13:14:04 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-09-01 16:46:32 +0530
commit05deb747bb18febb803b47119ca7bc432ffb80c8 (patch)
tree9b282436508c7029073168418beca578ce2f8207 /yt_dlp/jsinterp.py
parentb505e8517ad2ca8e07d5f9577dfd9a96165beaa0 (diff)
downloadhypervideo-pre-05deb747bb18febb803b47119ca7bc432ffb80c8.tar.lz
hypervideo-pre-05deb747bb18febb803b47119ca7bc432ffb80c8.tar.xz
hypervideo-pre-05deb747bb18febb803b47119ca7bc432ffb80c8.zip
[jsinterp] Fix escape in regex
Diffstat (limited to 'yt_dlp/jsinterp.py')
-rw-r--r--yt_dlp/jsinterp.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py
index 51c7beed4..27d7f0dfa 100644
--- a/yt_dlp/jsinterp.py
+++ b/yt_dlp/jsinterp.py
@@ -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)