From 221936958abadbe494a8c70bd0ceaf3e597d3d51 Mon Sep 17 00:00:00 2001 From: JulianMaurin Date: Thu, 27 Aug 2026 10:25:01 +0200 Subject: [PATCH] fix(stack): escape the HTML-comment delimiters in the revision marker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The revision-data marker rides inside ``, and a renderer closes an HTML comment at the first `-->`. A revision reason quoting one ended the marker early and spilled the remaining JSON into the pull request comment as visible text. The serialised payload now carries `--\u003e` and `\u003c!--` in place of `-->` and `"; +/// Neutralise the HTML-comment delimiters inside a serialised +/// marker payload. +/// +/// The marker rides inside ``, and a renderer closes an +/// HTML comment at the *first* `-->`. A `reason` that quotes one +/// therefore ends the marker early and spills the rest of the +/// JSON into the rendered comment as visible text. `\u003c` and +/// `\u003e` are the JSON escapes for `<` and `>`, so the payload +/// decodes to the exact same string — [`parse_marker_line`] +/// round-trips it, and markers written before this escape keep +/// parsing unchanged. +fn hide_html_comment_delimiters(json: &str) -> String { + json.replace("-->", "--\\u003e") + .replace("` verbatim. Left as-is it + // closes the marker's own HTML comment, and a renderer + // spills the remaining JSON into the PR comment as text. + let reason = "guard reads the stripped body, so `## Commit Message` cannot slip"; + let mut comment = RevisionHistoryComment::create_initial( + "https://api.github.com", + "o", + "r", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + ChangeType::Content, + t(), + reason, + None, + ); + comment.append( + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "cccccccccccccccccccccccccccccccccccccccc", + ChangeType::Rebase, + t(), + "after the quoting revision", + None, + ); + + let line = comment.marker_line(42); + // The only delimiters left are the marker's own. + assert_eq!(line.matches("-->").count(), 1); + assert!(line.ends_with(MARKER_SUFFIX)); + assert_eq!(line.matches("