From 6850fd69c6548618cf1ac7a0e0033654e2424072 Mon Sep 17 00:00:00 2001 From: Dustin Kaiser <8209087+mrnicegyu11@users.noreply.github.com> Date: Wed, 16 Oct 2024 03:34:45 +0200 Subject: [PATCH] Enhance email validation: Allow top-level domains with 5 letters (#2856) ### What problem does this PR solve? Currently singing up to ragflow using a mail-adress with associated top-level domains that have more than 4 chars will fail due to a regex validation that enforces just this. In our use case, we'd like to use e-mail addresses with `.swiss` top-level domains, which is a valid TLD associated with the country switzerland in the IANA root database. This change makes the validation accept 5-letter TLDs. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [x] Other (please describe): Making validation for lenient, accepting more valid input. --- api/apps/user_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/apps/user_app.py b/api/apps/user_app.py index 1535446d3..0c113dcde 100644 --- a/api/apps/user_app.py +++ b/api/apps/user_app.py @@ -354,7 +354,7 @@ def user_add(): email_address = req["email"] # Validate the email address - if not re.match(r"^[\w\._-]+@([\w_-]+\.)+[\w-]{2,4}$", email_address): + if not re.match(r"^[\w\._-]+@([\w_-]+\.)+[\w-]{2,5}$", email_address): return get_json_result(data=False, retmsg=f'Invalid email address: {email_address}!', retcode=RetCode.OPERATING_ERROR)