Skip to content

fix(core): refactor the old sanitizer to use discord.py's built-in - #19

Open
MikkelHebel wants to merge 2 commits into
ctfpilot:developfrom
Brunnerne:feature/7/sanitization
Open

fix(core): refactor the old sanitizer to use discord.py's built-in#19
MikkelHebel wants to merge 2 commits into
ctfpilot:developfrom
Brunnerne:feature/7/sanitization

Conversation

@MikkelHebel

Copy link
Copy Markdown
Member

Summary

Replaces the old markdown/mention sanitizer with discord.py's own built-in.

  • markdown_clean now uses discord.utils.escape_markdown
  • discord_clean now uses discord.utils.escape_markdown + discord.utils.escape_mentions, plus a small added regex to also break channel references (<#id>), since discord.py's mention escaping only covers @everyone/@here/user/role mentions and not channel links
  • Also configures the client with allowed_mentions=discord.AllowedMentions.none() as a second line of defense against pings.

Note: this escapes less aggressively than the old version, it only touches constructs that actually render as Markdown or a mention/reference, instead of blanket-escaping characters like {, (, ., ! that never meant anything in context. Same real coverage (formatting breakout, all four mention/reference types), just no more escaping for the sake of it.

This closes #7

@MikkelHebel MikkelHebel self-assigned this Jul 5, 2026
@MikkelHebel MikkelHebel changed the title Feature/7/sanitization fix(core): refactor the old sanitizer to use discord.py's built-in Jul 8, 2026
@The0mikkel

Copy link
Copy Markdown
Member

I'm setting this on hold, until #16 have been merged, as this PR needs to be updated aftwards.

@MikkelHebel
MikkelHebel force-pushed the feature/7/sanitization branch from 0dba115 to 56305a5 Compare July 31, 2026 22:16
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.

Update sanitization to use a more robust sanitization system

2 participants