From 416d2f83111466c63dcbedfe075b856f4a105e12 Mon Sep 17 00:00:00 2001 From: squid-protocol Date: Wed, 13 May 2026 06:59:13 -0400 Subject: [PATCH] perf(prism): optimize singular regex evaluation order to prevent ReDoS branch misses --- gitgalaxy/core/prism.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitgalaxy/core/prism.py b/gitgalaxy/core/prism.py index a57131d5..df5cfa07 100644 --- a/gitgalaxy/core/prism.py +++ b/gitgalaxy/core/prism.py @@ -286,7 +286,7 @@ def _calibrate_matrix(self) -> Dict[str, re.Pattern]: # word match. # 5. `%[^\n]*` : TeX and Matlab single-line comments. # ===================================================================== - p = r'(^[ \t]*%\{.*?%\}|;[^\n]*|//[^\n]*|(?i)\bdnl\b[^\n]*|%[^\n]*)' + p = r'(//[^\n]*|;[^\n]*|%[^\n]*|^[ \t]*%\{.*?%\}|(?i)\bdnl\b[^\n]*)' if p: try: