diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-10-11 07:59:27 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-10-11 08:02:26 +0530 |
commit | 0468a3b3253957bfbeb98b4a7c71542ff80e9e06 (patch) | |
tree | 6fd39f334a933dba146bff5a15fd6a1421d29d16 /yt_dlp/jsinterp.py | |
parent | d509c1f5a347d0247593f116fa5cad2ff4f9a3de (diff) | |
download | hypervideo-pre-0468a3b3253957bfbeb98b4a7c71542ff80e9e06.tar.lz hypervideo-pre-0468a3b3253957bfbeb98b4a7c71542ff80e9e06.tar.xz hypervideo-pre-0468a3b3253957bfbeb98b4a7c71542ff80e9e06.zip |
[jsinterp] Improve separating regex
Fixes https://github.com/yt-dlp/yt-dlp/issues/4635#issuecomment-1273974909
Diffstat (limited to 'yt_dlp/jsinterp.py')
-rw-r--r-- | yt_dlp/jsinterp.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py index 4caad6f74..e25997129 100644 --- a/yt_dlp/jsinterp.py +++ b/yt_dlp/jsinterp.py @@ -236,7 +236,7 @@ class JSInterpreter: @staticmethod def _separate(expr, delim=',', max_split=None): - OP_CHARS = '+-*/%&|^=<>!,;{}:' + OP_CHARS = '+-*/%&|^=<>!,;{}:[' if not expr: return counters = {k: 0 for k in _MATCHING_PARENS.values()} @@ -246,7 +246,9 @@ class JSInterpreter: if not in_quote and char in _MATCHING_PARENS: counters[_MATCHING_PARENS[char]] += 1 elif not in_quote and char in counters: - counters[char] -= 1 + # Something's wrong if we get negative, but ignore it anyway + if counters[char]: + counters[char] -= 1 elif not escaping: if char in _QUOTES and in_quote in (char, None): if in_quote or after_op or char != '/': |