Harden fenced markdown rendering against code-fence breakout and mention abuse#534
Closed
Harden fenced markdown rendering against code-fence breakout and mention abuse#534
Conversation
…n abuse Agent-Logs-Url: https://github.com/statch/gitbot/sessions/71de78f4-95f9-4b00-bbde-4a621af540f1 Co-authored-by: seven7ty <63970738+seven7ty@users.noreply.github.com>
Agent-Logs-Url: https://github.com/statch/gitbot/sessions/71de78f4-95f9-4b00-bbde-4a621af540f1 Co-authored-by: seven7ty <63970738+seven7ty@users.noreply.github.com>
Agent-Logs-Url: https://github.com/statch/gitbot/sessions/71de78f4-95f9-4b00-bbde-4a621af540f1 Co-authored-by: seven7ty <63970738+seven7ty@users.noreply.github.com>
Agent-Logs-Url: https://github.com/statch/gitbot/sessions/46b730a3-a822-49cd-9473-c994c6dd7db6 Co-authored-by: seven7ty <63970738+seven7ty@users.noreply.github.com>
Agent-Logs-Url: https://github.com/statch/gitbot/sessions/46b730a3-a822-49cd-9473-c994c6dd7db6 Co-authored-by: seven7ty <63970738+seven7ty@users.noreply.github.com>
Agent-Logs-Url: https://github.com/statch/gitbot/sessions/46b730a3-a822-49cd-9473-c994c6dd7db6 Co-authored-by: seven7ty <63970738+seven7ty@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
seven7ty
April 10, 2026 21:23
View session
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
sanitize_codeblock_content, usingif not content:will convert falsy values like0to an empty string; consider changing this to an explicitif content is None:check so numeric or boolean values are preserved when passed in. - You currently rely on callers to remember
neutralize_mentions=Falsefor code-centric paths (snippets, gists, etc.); consider adding small helper wrappers likesanitize_code()vssanitize_text()or defaulting based on context to reduce the chance of accidentally neutralizing@in future code views.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `sanitize_codeblock_content`, using `if not content:` will convert falsy values like `0` to an empty string; consider changing this to an explicit `if content is None:` check so numeric or boolean values are preserved when passed in.
- You currently rely on callers to remember `neutralize_mentions=False` for code-centric paths (snippets, gists, etc.); consider adding small helper wrappers like `sanitize_code()` vs `sanitize_text()` or defaulting based on context to reduce the chance of accidentally neutralizing `@` in future code views.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Hi! This is your first pull request, we're glad to have you with us 😄 Make sure to follow the contribution guidelines. Happy coding!
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.
This change closes remaining markdown injection surfaces where untrusted external text was interpolated into fenced Discord output.
Scope of hardening
Sanitizer behavior
Manager.sanitize_codeblock_content(...).~~~Parity-preserving exception for code views
@characters and copy/paste fidelity.Representative usage
Summary by Sourcery
Harden Discord fenced markdown rendering for untrusted external text and error outputs by centralizing sanitization of content embedded in code blocks.
Bug Fixes:
Enhancements:
Summary by Sourcery
Harden Discord embed rendering by sanitizing untrusted text before interpolation into fenced code blocks.
Bug Fixes:
Enhancements: