diff --git a/.github/scripts/issue-version-triage.cjs b/.github/scripts/issue-version-triage.cjs index 95a860cb60..12900f1d56 100644 --- a/.github/scripts/issue-version-triage.cjs +++ b/.github/scripts/issue-version-triage.cjs @@ -185,7 +185,7 @@ function firstFieldValue(lines, start = 0) { return ""; } -function extractSectionValues(body, heading, followingHeadings = [], report = parseReportMarkdown(body)) { +function extractSectionValues(body, heading, followingHeadings = [], report = parseReportMarkdown(body), declarationsOnly = false) { if (!body) return []; const lines = report.lines; const pattern = new RegExp(`^${escapeRegExp(heading)}$`, "i"); @@ -200,7 +200,8 @@ function extractSectionValues(body, heading, followingHeadings = [], report = pa boundary.test(lines[end].heading))))) { end += 1; } - values.push(lines.slice(start + 1, end).map((line) => line.text).join("\n").trim()); + values.push(lines.slice(start + 1, end).map((line) => + !declarationsOnly || line.declaration ? line.text : "").join("\n").trim()); // A deeper, form-named subheading is part of this value, not another // declaration. Only resume at the boundary that ended the field. start = end - 1; @@ -433,7 +434,9 @@ function classifyFeedbackSelection(feedbackType, report) { } function classifyV6FeedbackType(body, report = parseReportMarkdown(body)) { - const classes = extractSectionValues(body, "Feedback type", [], report) + // Preserve the report's original block context. Re-lexing copied code or a + // quote as bare field text could let examples supply or veto a selection. + const classes = extractSectionValues(body, "Feedback type", [], report, true) .map(value => classifyFeedbackSelection(value, report)); // Repeated declarations must agree on the metadata category. Choosing the // first can invent a bug and its version requirements from contradictory or diff --git a/.github/scripts/issue-version-triage.test.cjs b/.github/scripts/issue-version-triage.test.cjs index 3563df5b06..13e7898008 100644 --- a/.github/scripts/issue-version-triage.test.cjs +++ b/.github/scripts/issue-version-triage.test.cjs @@ -498,8 +498,6 @@ test("feedback classification examines the complete field instead of its first l "Documentation issue\nBug / regression", "Bug / regression\nThis is a question, not a selected form option.", "Documentation issue\n\nBug / regression", - "Bug / regression\n\n> Documentation issue", - "Bug / regression\n\n```text\nDocumentation issue\n```", "Bug / regression\n\n", "Bug / regression\n\n- Documentation issue", ]) { @@ -526,6 +524,26 @@ test("a complete single choice retains wrapping, hidden comments and shared refe } }); +test("copied blocks cannot supply or contradict a feedback selection", () => { + for (const copied of [ + "> Documentation issue", + "```text\nDocumentation issue\n```", + " Documentation issue", + "