Skip to content

fix(sanitize): preserve angle brackets inside markdown code#2633

Open
advancedresearcharray wants to merge 1 commit into
github:mainfrom
advancedresearcharray:fix/preserve-angle-brackets-in-code-2202
Open

fix(sanitize): preserve angle brackets inside markdown code#2633
advancedresearcharray wants to merge 1 commit into
github:mainfrom
advancedresearcharray:fix/preserve-angle-brackets-in-code-2202

Conversation

@advancedresearcharray
Copy link
Copy Markdown

@advancedresearcharray advancedresearcharray commented Jun 6, 2026

Summary

  • Fix issue read responses dropping text like <int> inside markdown code blocks because bluemonday.StrictPolicy() treats unknown angle-bracket tokens as HTML tags
  • Protect < and > inside fenced code blocks and inline code spans with sentinels before HTML sanitization, then restore them afterward
  • Strip NUL bytes before protection to prevent sentinel collision attacks

Root cause

FilterHTMLTags runs bluemonday on the full issue/PR body. Content such as mut_raw_ptr<int> is parsed as an unrecognized HTML tag and removed, so MCP clients see mut_raw_ptr instead.

Test plan

  • go test ./pkg/sanitize/...
  • go test ./pkg/github/... -run Test_GetIssue_PreservesAngleBracketsInCodeBlocks
  • ./script/lint
  • Verified fenced code blocks preserve mut_raw_ptr<int>
  • Verified inline code preserves Vec<String>
  • Verified <script> outside code is still stripped

Closes #2202

Protect angle brackets in fenced and inline code before bluemonday HTML
sanitization so generic type syntax like mut_raw_ptr<int> is not stripped
from issue and PR bodies returned by MCP tools.

Closes github#2202
@advancedresearcharray advancedresearcharray force-pushed the fix/preserve-angle-brackets-in-code-2202 branch from a797a54 to 392d70d Compare June 6, 2026 23:09
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.

GitHub MCP issue read appears to drop code block text in angle brackets

1 participant