From 7a9313d5a5a07ac2eea70d895c3c00d566af4bfd Mon Sep 17 00:00:00 2001 From: AllfatherHatt Date: Sun, 18 May 2025 13:07:11 +0200 Subject: [PATCH] Removing unsupported escape character --- recruitmentCog/recruitment.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/recruitmentCog/recruitment.py b/recruitmentCog/recruitment.py index 70f72da..6b16707 100644 --- a/recruitmentCog/recruitment.py +++ b/recruitmentCog/recruitment.py @@ -51,13 +51,16 @@ QUESTIONS_LIST = [ def sanitize_input(input_text: str) -> str: """Sanitize input to remove mentions, links, and unwanted special characters.""" + # Remove user/role/channel mentions text = re.sub(r'<@!?(?:&)?\d+>', '', input_text) + # Remove URLs text = re.sub(r'http\S+', '', text) - # Allow unicode letters and common punctuation - text = re.sub(r'[^\w\s\p{L}\.,\?!`~@#$%^&*()_+=-]', '', text) + # Keep only word characters (including Unicode letters/digits), whitespace, and your chosen punctuation + text = re.sub(r"[^\w\s\.,\?!`~@#$%^&*()_+=-]", "", text) return text + class Recruitment(commands.Cog): # noqa """A cog that lets a user send a membership application."""