github-mcp-server icon indicating copy to clipboard operation
github-mcp-server copied to clipboard

fix(sanitize): preserve angle brackets inside markdown code

Open advancedresearcharray opened this issue 5 months ago • 1 comments

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

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

Closes #2202

advancedresearcharray avatar Jun 06 '26 22:06 advancedresearcharray

Merge-ready check-in

This PR looks ready for maintainer review/merge when you have a moment.

  • Change: fix(sanitize): preserve angle brackets inside markdown code
  • CI: green / passing
  • Review: REVIEW_REQUIRED (mergeable: MERGEABLE)

Happy to rebase or address any remaining feedback. Thanks for maintaining the project.

advancedresearcharray avatar Jun 12 '26 17:06 advancedresearcharray