Skip to content

[BUGFIX] Panel description: escape HTML nested in raw inline tags - #463

Merged
Gladorme merged 1 commit into
perses:mainfrom
Gladorme:agents/description-escape-nested-html
Nov 26, 2026
Merged

Gladorme merged 1 commit into
perses:mainfrom
Gladorme:agents/description-escape-nested-html

Conversation

@Gladorme

@Gladorme Gladorme commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Description

Follow-up to #380, raised by @jgbernalp in perses/plugins#905.

Panel descriptions escape raw HTML by overriding the marked html renderer. That does not cover everything: when marked sees a raw <code>, <kbd>, <pre>, ... opening tag, it outputs the content that follows unescaped. For example:

prefix <code><img/src=//example.com/tracker></code>

<code> and </code> are escaped, but the <img> stays real HTML. DOMPurify allows <img src>, so the image is loaded when the description tooltip is shown. Scripts and event handlers are still removed by DOMPurify, so this is not script injection, but raw HTML is supposed to be displayed as text.

This PR disables the html and tag tokenizers instead, so raw HTML is never tokenized and is always escaped as plain text. Markdown, inline code, links, <https://…> autolinks and entities render as before.

One visible difference: a raw HTML block such as <div>\nblock\n</div> was output as bare escaped text, and is now rendered as escaped text inside <p> elements, like any other text.

Tests:

  • Added prefix <code><img/src=//example.com/tracker></code> to the raw HTML cases. It fails on main and passes with this change.
  • The raw HTML block assertion now checks the rendered DOM (no <div> element, tags displayed as text) rather than the exact HTML string.

Validation:

  • npm run test -w dashboards: passed (259 tests).
  • npx turbo run type-check --filter=@perses-dev/dashboards: passed.
  • npx oxlint dashboards/src: 70 warnings, same as main.
  • npm run format:check: passed.

Screenshots

No layout change: raw HTML in descriptions was already displayed as text, this fixes the cases where it was not.

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • E2E tests are stable and unlikely to be flaky.
    See e2e docs for more details. Common issues include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

Escaping raw HTML in the marked html renderer did not cover everything: the content following a raw <code>, <kbd> or <pre> tag was still output as HTML, so e.g. an <img> nested in <code> was rendered and loaded in the description tooltip. Raw HTML is now not tokenized at all, so it is escaped as plain text.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
@Gladorme
Gladorme marked this pull request as ready for review November 26, 2026 15:08
@Gladorme
Gladorme requested a review from a team as a code owner November 26, 2026 15:08
@Gladorme
Gladorme merged commit cf3e446 into perses:main Nov 26, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants