| From 97eb3d5ec7c1b3ea4fcf9dee30a2309cf92bd194 Mon Sep 17 00:00:00 2001 |
| From: Jean Abou Samra <jean@abou-samra.fr> |
| Date: Wed, 1 Mar 2023 00:58:35 +0100 |
| Subject: [PATCH] SQL+Jinja: use a simpler regex in analyse_text |
| |
| Fixes catastrophic backtracking |
| |
| Fixes #2355 |
| --- |
| pygments/lexers/templates.py | 6 +----- |
| 1 file changed, 1 insertion(+), 5 deletions(-) |
| |
| diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py |
| index 1fcf70856d..106629433d 100644 |
| --- a/pygments/lexers/templates.py |
| +++ b/pygments/lexers/templates.py |
| @@ -2291,10 +2291,6 @@ def analyse_text(text): |
| 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 |