Skip to content

Fix the wavedrom extra bypassing safe_mode - #767

Open
adityaanikam wants to merge 1 commit into
trentm:masterfrom
adityaanikam:fix-wavedrom-safe-mode
Open

adityaanikam wants to merge 1 commit into
trentm:masterfrom
adityaanikam:fix-wavedrom-safe-mode

Conversation

@adityaanikam

@adityaanikam adityaanikam commented Nov 5, 2026 •

Copy link
Copy Markdown

Fixes #765.

The wavedrom extra hashes the content of its fenced block before safe_mode sanitizes the HTML, so a block like <script>...</script> or <img onerror=...> was restored unescaped in both the escape and replace modes. The content is now passed through _sanitize_html when safe_mode is set, which is also what already happens to the <script type="WaveDrom"> tags around it.

One behaviour change to be aware of: with the wavedrom library installed and SVG embedding on, the generated SVG used to be restored raw in safe mode (next to an escaped <div> wrapper), so the diagram rendered. With this change it is escaped like the rest. I did not find an input that makes the library emit a raw tag, so if you would rather keep that path as it is, I can limit the change to the script tag path.

Added two test cases, one per mode. They fail on master and pass with this change.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 10:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@adityaanikam
adityaanikam force-pushed the fix-wavedrom-safe-mode branch from 2b1a342 to ecfd928 Compare November 5, 2026 10:31
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.

wavedrom extra bypasses safe_mode and allows XSS

2 participants