diff options
author | Jean Abou Samra <jean@abou-samra.fr> | 2023-03-01 00:58:35 +0100 |
---|---|---|
committer | Jean Abou Samra <jean@abou-samra.fr> | 2023-03-01 01:01:47 +0100 |
commit | 97eb3d5ec7c1b3ea4fcf9dee30a2309cf92bd194 (patch) | |
tree | b471f9d25c36f8f5c600b4d46caef65077828779 | |
parent | 5f8c54198ed6bf84c3e116fa72426aaf8b4e8f57 (diff) | |
download | pygments-git-97eb3d5ec7c1b3ea4fcf9dee30a2309cf92bd194.tar.gz |
SQL+Jinja: use a simpler regex in analyse_text
Fixes catastrophic backtracking
Fixes #2355
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | pygments/lexers/templates.py | 6 |
2 files changed, 2 insertions, 5 deletions
@@ -24,6 +24,7 @@ Version 2.15.0 parameters (#2359), improve lexing of variable variable syntax (#2358) * Python: add missing builtins (#2334) * Spice: update keywords (#2336) + * SQL+Jinja (``analyse_text`` method): fix catastrophic backtracking - Declare support for Python 3.11 and drop support for Python 3.6 (#2324). - Update ``native`` style to improve contrast (#2325). diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py index 1fcf7085..10662943 100644 --- a/pygments/lexers/templates.py +++ b/pygments/lexers/templates.py @@ -2291,10 +2291,6 @@ class SqlJinjaLexer(DelegatingLexer): if re.search(r'\{\{\s*source\(.*\)\s*\}\}', text): rv += 0.25 # Jinja macro - if re.search( - r'\{%-?\s*macro \w+\(.*\)\s*-?%\}\s+.*\s+\{%-?\s*endmacro\s*-?%\}', - text, - re.S, - ): + if re.search(r'\{%-?\s*macro \w+\(.*\)\s*-?%\}', text): rv += 0.15 return rv |