Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Fix CodeQL security vulnerability in CSS prefix check regex

LearningCircuit705487a6417a
diff --git a/.pre-commit-hooks/check-css-class-prefix.py b/.pre-commit-hooks/check-css-class-prefix.py
index ed7618fe62..9587592595 100755
--- a/.pre-commit-hooks/check-css-class-prefix.py
+++ b/.pre-commit-hooks/check-css-class-prefix.py
@@ -130,12 +130,13 @@ def check_html_file(file_path: Path) -> List[Tuple[int, str, str]]:
lines = content.split("\n")
# Pattern to match class attributes in HTML
- # This pattern handles Jinja2 templates with nested quotes
- # Matches: class="..." or class='...' including Jinja2 expressions
- class_attr_pattern = re.compile(
- r'class\s*=\s*"([^"]*(?:\{[^}]*\}[^"]*)*)"|class\s*=\s*\'([^\']*(?:\{[^}]*\}[^\']*)*)\'',
- re.IGNORECASE,
- )
+ # Simplified pattern to avoid exponential backtracking
+ # Matches: class="..." or class='...'
+ # Uses two separate patterns to handle each quote type correctly
+ class_attr_patterns = [
+ re.compile(r'class\s*=\s*"([^"]*)"', re.IGNORECASE),
+ re.compile(r"class\s*=\s*'([^']*)'", re.IGNORECASE),
+ ]
for line_num, line in enumerate(lines, 1):
# Skip HTML comments
@@ -146,11 +147,12 @@ def check_html_file(file_path: Path) -> List[Tuple[int, str, str]]:
if "{#" in line or "#}" in line:
continue
- matches = class_attr_pattern.findall(line)
- for match in matches:
- # The regex has two groups - one for double quotes, one for single quotes
- # Get whichever one matched
- class_attr = match[0] if match[0] else match[1]
+ # Try both patterns to handle different quote types
+ matches = []
+ for pattern in class_attr_patterns:
+ matches.extend(pattern.findall(line))
+
+ for class_attr in matches:
# Skip if the entire class attribute contains Jinja2 template variables
# This handles cases like class="alert alert-{{ category }}"
if "{{" in class_attr or "{%" in class_attr: