From 73f6784277edc1c6c99a344810b5f647f71a60fe Mon Sep 17 00:00:00 2001 From: Siddhesh Ghadi Date: Fri, 27 Nov 2026 13:04:16 +0530 Subject: [PATCH 1/2] fix: replace quadratic regex with line-scoped search in check-published-numbers The patterns at lines 60 and 76 used [^|]* (unbounded) followed by a required | literal, causing quadratic backtracking on crafted README input. Replace with a plain line lookup followed by a regex applied only to that bounded line, making the scan linear. No behavior change on well-formed tables. Thanks to Jiawei Guo for the careful analysis that surfaced this. Co-Authored-By: Claude Sonnet 4.6 --- scripts/check-published-numbers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/check-published-numbers.py b/scripts/check-published-numbers.py index 8afe59a..4cff501 100755 --- a/scripts/check-published-numbers.py +++ b/scripts/check-published-numbers.py @@ -57,7 +57,11 @@ def check(where, label, got, want): # root README table readme = (ROOT / "README.md").read_text() for s, (w, b, _) in truth.items(): - m = re.search(rf"\[`{re.escape(s)}`\][^|]*\|\s*\**([\d.]+)%\**\s*\|\s*\**([\d.]+)%\**", readme) + row = next((l for l in readme.splitlines() if f"[`{s}`]" in l), None) + if not row: + problems.append(f"README.md: no row for {s}") + continue + m = re.search(r"\|\s*\**([\d.]+)%\**\s*\|\s*\**([\d.]+)%\**", row) if not m: problems.append(f"README.md: no row for {s}") continue @@ -73,7 +77,11 @@ def check(where, label, got, want): # benchmarks/README.md table bench = (ROOT / "benchmarks" / "README.md").read_text() for s, (w, b, _) in truth.items(): - m = re.search(rf"`{re.escape(s)}`\s*\|\s*\**([\d.]+)%\**\s*\|\s*\**?([\d.]+)%", bench) + row = next((l for l in bench.splitlines() if f"`{s}`" in l), None) + if not row: + problems.append(f"benchmarks/README.md: no row for {s}") + continue + m = re.search(r"\|\s*\**([\d.]+)%\**\s*\|\s*\**?([\d.]+)%", row) if not m: problems.append(f"benchmarks/README.md: no row for {s}") continue From 30803339e7c9e064bef89f23753788df6b1a59b3 Mon Sep 17 00:00:00 2001 From: Siddhesh Ghadi Date: Fri, 27 Nov 2026 13:21:01 +0530 Subject: [PATCH 2/2] fix: tighten table row matching in check-published-numbers Restrict row lookup to lines starting with | (actual table rows) and check the skill name against the first column only, preventing false matches against prose mentions or unrelated table columns. Also move splitlines() outside the per-skill loop. Co-Authored-By: Claude Sonnet 4.6 --- scripts/check-published-numbers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/check-published-numbers.py b/scripts/check-published-numbers.py index 4cff501..f5b8de7 100755 --- a/scripts/check-published-numbers.py +++ b/scripts/check-published-numbers.py @@ -56,8 +56,9 @@ def check(where, label, got, want): # root README table readme = (ROOT / "README.md").read_text() + readme_rows = [l for l in readme.splitlines() if l.startswith("|")] for s, (w, b, _) in truth.items(): - row = next((l for l in readme.splitlines() if f"[`{s}`]" in l), None) + row = next((l for l in readme_rows if f"[`{s}`]" in l.split("|")[1]), None) if not row: problems.append(f"README.md: no row for {s}") continue @@ -76,8 +77,9 @@ def check(where, label, got, want): # benchmarks/README.md table bench = (ROOT / "benchmarks" / "README.md").read_text() + bench_rows = [l for l in bench.splitlines() if l.startswith("|")] for s, (w, b, _) in truth.items(): - row = next((l for l in bench.splitlines() if f"`{s}`" in l), None) + row = next((l for l in bench_rows if f"`{s}`" in l.split("|")[1]), None) if not row: problems.append(f"benchmarks/README.md: no row for {s}") continue