Repository navigation
[BUGFIX] Panel description: escape HTML nested in raw inline tags - #463
Merged
Gladorme merged 1 commit intoNov 26, 2026
Merged
Conversation
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
marked this pull request as ready for review
November 26, 2026 15:08
AntoineThebaud
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #380, raised by @jgbernalp in perses/plugins#905.
Panel descriptions escape raw HTML by overriding the
markedhtmlrenderer. That does not cover everything: whenmarkedsees a raw<code>,<kbd>,<pre>, ... opening tag, it outputs the content that follows unescaped. For example:<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
htmlandtagtokenizers 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:
prefix <code><img/src=//example.com/tracker></code>to the raw HTML cases. It fails onmainand passes with this change.<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 asmain.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
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes
See e2e docs for more details. Common issues include: