You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(markdown): preserve SVG tags in code blocks (#707)
# Motivation
The `Markdown` component converts markdown into HTML. For security
reasons, the input is sanitized before transformation.
The initial implementation was introduced
[here](dfinity/nns-dapp#3399) and acknowledged
this edge case.
> It's not possible to use the HTML renderer since the SVG contains
multiple tags.
> One edge case remains unaddressed: if the SVG is inside the `<code>`
tag, it will be rendered with < and > instead of "<" and ">."
We need to address this use case now, as there is a mismatch between how
the proposal is rendered and how it should be rendered:
*
https://nns.ic0.app/proposal/?u=qoctq-giaaa-aaaaa-aaaea-cai&proposal=138188
* https://dashboard.internetcomputer.org/proposal/138188
# Changes
* Do not escape svg's inside code blocks.
# Screenshots
<img width="1013" height="847" alt="Screenshot 2025-08-27 at 15 42 30"
src="https://github.com/user-attachments/assets/0c9ceb4e-1806-491d-bb17-99e68fa9b096"
/>
// Replace the SVG elements in the HTML with their escaped versions to improve security.
98
132
// It's not possible to do it with html renderer because the svg consists of multiple tags.
99
-
// One edge case is not covered: if the svg is inside the <code> tag, it will be rendered as with < & > instead of "<" & ">"
100
133
constescapedText=escapeSvgs(text);
101
134
102
135
// The dynamic import cannot be analyzed by Vite. As it is intended, we use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
0 commit comments