From b4e14a89341a214f4fb4a0d777ea251997461c12 Mon Sep 17 00:00:00 2001 From: luvs01 Date: Fri, 7 Aug 2026 16:13:36 +0900 Subject: [PATCH] fix(issue-quality): bound reproduction matching cost --- .github/scripts/issue-quality.cjs | 17 ++++++++++------- .github/scripts/issue-quality.test.cjs | 6 ++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/scripts/issue-quality.cjs b/.github/scripts/issue-quality.cjs index 1c0a6430a..5c63ac76f 100644 --- a/.github/scripts/issue-quality.cjs +++ b/.github/scripts/issue-quality.cjs @@ -1087,13 +1087,8 @@ const REPRO_PATH_RE = new RegExp([ "~?/[\\w.@-]+(?:/[\\w.@-]+)+", "[A-Za-z]:\\\\(?:[\\w.@-]+\\\\)+[\\w.@-]+", "~?/[\\w.@-]+/[\\w.@-]+\\.(?:json|yaml|yml|toml|conf|log|env|txt|ts|js|tsx|jsx|sh|ps1|py)", - "[\\w.@-]+\\.(?:json|yaml|yml|toml|conf|log|env)\\b", + "(?:^|[^\\w.@-])[\\w.@-]+\\.(?:json|yaml|yml|toml|conf|log|env)\\b", ].join("|")); -const ACTIONABLE_REPRO_RE = new RegExp( - [REPRO_COMMAND_RE.source, REPRO_FAILURE_RE.source, REPRO_PATH_RE.source].join("|"), - "i", -); - // Sigil-only fences with no body content are never actionable. const EMPTY_FENCE_RE = /^[ \t]{0,3}(?:```+|~~~+)\s*\n\s*\n[ \t]{0,3}(?:```+|~~~+)\s*$/; @@ -1104,9 +1099,17 @@ const EMPTY_FENCE_RE = /^[ \t]{0,3}(?:```+|~~~+)\s*\n\s*\n[ \t]{0,3}(?:```+|~~~+ * count as actionable when their body contains non-whitespace content. */ function hasActionableReproductionDetail(text) { + if (typeof text !== "string") return false; + // Reject text with no actionable syntax before clean() performs Markdown + // media handling, which is unnecessary for a plain non-matching token. + if (!/[./\\`~]/.test(text) && !REPRO_COMMAND_RE.test(text) && !REPRO_FAILURE_RE.test(text)) { + return false; + } const c = clean(text); if (!c) return false; - if (ACTIONABLE_REPRO_RE.test(c)) return true; + if (REPRO_COMMAND_RE.test(c) || REPRO_FAILURE_RE.test(c)) return true; + // Avoid running path patterns over long tokens that cannot contain a path. + if (/[./\\]/.test(c) && REPRO_PATH_RE.test(c)) return true; // Fenced blocks: only count when the body has non-whitespace content. if (/```|~~~/.test(c)) { const parts = stripFencedActionableContent(c); diff --git a/.github/scripts/issue-quality.test.cjs b/.github/scripts/issue-quality.test.cjs index 4f22c4247..01a9ecf8c 100644 --- a/.github/scripts/issue-quality.test.cjs +++ b/.github/scripts/issue-quality.test.cjs @@ -654,6 +654,12 @@ describe("validateIssue - feature", () => { assert.equal(hasActionableReproductionDetail("```\nSIGSEGV at 0x0000\n```"), true); }); + it("checks long non-matching reproduction tokens in linear time", () => { + const startedAt = performance.now(); + assert.equal(hasActionableReproductionDetail("a".repeat(60_000)), false); + assert.ok(performance.now() - startedAt < 500, "actionable reproduction check took too long"); + }); + it("rejects fenced placeholder-only examples", () => { const fencedPlaceholders = [ "```\nN/A\n```",