fix(safe-outputs): preserve custom XML tags, only escape known HTML/SVG elements#18327
Closed
fix(safe-outputs): preserve custom XML tags, only escape known HTML/SVG elements#18327
Conversation
Custom XML tags (e.g., MSBuild's AppendTargetFrameworkToOutputPath) are no longer converted to parentheses. Only known HTML5 and SVG elements are converted to prevent HTML injection, since GitHub's markdown renderer cannot interpret custom XML as HTML anyway. Fixes: safe-outputs add-comment strips < and > from markdown code blocks Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix safe-outputs sanitizer issue with markdown code blocks
fix(safe-outputs): preserve custom XML tags, only escape known HTML/SVG elements
Feb 25, 2026
Copilot stopped work on behalf of
pelikhan due to an error
February 25, 2026 12:15
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.
The safe-outputs sanitizer was converting all unrecognized tags to parentheses — including custom XML like MSBuild's
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>, which would be mangled to(AppendTargetFrameworkToOutputPath)false(/AppendTargetFrameworkToOutputPath)even inside markdown code fences.Changes
sanitize_content_core.cjs: ChangedconvertXmlTags()from an allowlist model (preserve GFM-safe tags, convert everything else) to a denylist model (only convert known HTML5 + SVG + MathML elements). Custom XML tags — anything not in the standard web vocabulary — pass through unchanged.onload, etc.)mathroot element includedsanitize_content.test.cjs: Added tests covering custom XML preservation and confirming known HTML elements are still converted.Behavior
Known injection vectors are unchanged —
<div>,<script>,<svg onload="...">etc. are still converted to parentheses.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.