From 01cff04c28455ada84fa41b3ee8ccbcce4c315b8 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 17 Sep 2025 21:06:17 +0530 Subject: [PATCH] fix: capture all kinds of emails in workspace-invite csv input --- routers/workspace.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/routers/workspace.py b/routers/workspace.py index 0b59a3162..22aa4d8f9 100644 --- a/routers/workspace.py +++ b/routers/workspace.py @@ -289,15 +289,14 @@ def popup_close_or_navgiate_js(next_url: str) -> str: ) -delimiters = re.compile(r"[\s,;|]+") +email_re = re.compile(r"[\w\-\.+%]+@(?:[\w-]+\.)+[\w-]{2,}") def validate_emails_csv(emails_csv: str, max_emails: int = 5) -> list[str]: """Raises ValidationError if an email is invalid""" - emails = [email.lower().strip() for email in delimiters.split(emails_csv)] - emails = filter(bool, emails) # remove empty strings - emails = set(emails) # remove duplicates + emails = email_re.findall(emails_csv) + emails = {email.lower() for email in emails} # lowercase + remove duplicates emails = list(emails)[:max_emails] # take up to max_emails from the list error_messages = []