From 1f5eed93feede0dd93e8c58b512ff17a207d91cb Mon Sep 17 00:00:00 2001 From: ticccco <23436953+LucasPlacentino@users.noreply.github.com> Date: Sat, 30 Mar 2024 13:32:10 +0100 Subject: [PATCH] fix: filter names to remove unwanted characters only keep ASCII letters and spaces --- classes/registration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/registration.py b/classes/registration.py index a39ed85..fd72732 100644 --- a/classes/registration.py +++ b/classes/registration.py @@ -9,6 +9,7 @@ from typing import Dict from typing import List from typing import Tuple +from string import ascii_letters import disnake from disnake.ext import commands @@ -519,7 +520,10 @@ async def _register_user_step(self, inter: disnake.ModalInteraction) -> None: The modal interaction that triggered the step """ # Extract name and store the user - name = " ".join([name.title() for name in self.email.split("@")[0].split(".")]) + allowed_chars = set(ascii_letters + " ") # or set('abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ') + unfiltered_name = " ".join([name.title() for name in self.email.split("@")[0].split(".")]) + name = "".join(filter(allowed_chars.__contains__, unfiltered_name)) # remove all characters that aren't ASCII letters or a space + logging.trace(f"[RegistrationForm] [User:{self.target.id}] Extracted name from email= {name}") Database.set_user(self.target, name, self.email) await self._stop()