Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize markdown in GitHub entity titles #164

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

00-kat
Copy link
Contributor

@00-kat 00-kat commented Feb 24, 2025

Closes #149.

Continuation of #156, thank you GitHub.

@@ -43,7 +44,8 @@ async def load_emojis() -> None:


def _format_mention(entity: Entity, kind: EntityKind) -> str:
headline = ENTITY_TEMPLATE.format(kind=kind, entity=entity)
title = escape_special(entity.title)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I should inline this; I liked the formatting with the new title variable more, and it's more consistent with the rest of them, so I kept it this way. Let me know if you want it changed.

@@ -101,3 +106,24 @@ async def remove_view_after_timeout(
await asyncio.sleep(timeout)
with suppress(discord.NotFound, discord.HTTPException):
await message.edit(view=None)


def escape_special(s: str) -> str:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: for some performance characteristics, there are five regexes run in this function.

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.

Markdown in GitHub entity titles are not sanitised
1 participant