From 422f005c3f85b444adf569b129807551b08d14d2 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Tue, 19 Dec 2023 18:25:04 +0100 Subject: [PATCH 1/3] Fix 3095 --- core/admin/mailu/ui/forms.py | 2 +- towncrier/newsfragments/3095.bugfix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 towncrier/newsfragments/3095.bugfix diff --git a/core/admin/mailu/ui/forms.py b/core/admin/mailu/ui/forms.py index 79b1445d..bfc7a84f 100644 --- a/core/admin/mailu/ui/forms.py +++ b/core/admin/mailu/ui/forms.py @@ -39,7 +39,7 @@ class MultipleEmailAddressesVerify(object): def __call__(self, form, field): pattern = re.compile(r'^([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{1,})(,([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{2,}))*$') - if not pattern.match(field.data.replace(" ", "")): + if not pattern.match(field.data.lower().replace(" ", "")): raise validators.ValidationError(self.message) class MultipleFoldersVerify(object): diff --git a/towncrier/newsfragments/3095.bugfix b/towncrier/newsfragments/3095.bugfix new file mode 100644 index 00000000..73f37281 --- /dev/null +++ b/towncrier/newsfragments/3095.bugfix @@ -0,0 +1 @@ +Ensure that the form validator related to forwarding addresses allows for uppercase From 30574445e457e4562443cde0dbdcd8146c2fbc1a Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Wed, 20 Dec 2023 11:41:45 +0100 Subject: [PATCH 2/3] Better regexp --- core/admin/mailu/ui/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/admin/mailu/ui/forms.py b/core/admin/mailu/ui/forms.py index bfc7a84f..4906417e 100644 --- a/core/admin/mailu/ui/forms.py +++ b/core/admin/mailu/ui/forms.py @@ -38,8 +38,8 @@ class MultipleEmailAddressesVerify(object): self.message = message def __call__(self, form, field): - pattern = re.compile(r'^([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{1,})(,([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{2,}))*$') - if not pattern.match(field.data.lower().replace(" ", "")): + pattern = re.compile(r"^(?:\s*\S+@([a-z0-9\-]{1,}\.)*([a-z]{1,})[\s|,]*)+$", re.IGNORECASE) + if not pattern.match(field.data.replace(" ", "")): raise validators.ValidationError(self.message) class MultipleFoldersVerify(object): From 98848b45c7ef4bf0f01762411777b4f36e334f9e Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Wed, 20 Dec 2023 12:06:44 +0100 Subject: [PATCH 3/3] Do the minimum to solve the problem at hand --- core/admin/mailu/ui/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/admin/mailu/ui/forms.py b/core/admin/mailu/ui/forms.py index 4906417e..b6c45189 100644 --- a/core/admin/mailu/ui/forms.py +++ b/core/admin/mailu/ui/forms.py @@ -38,7 +38,7 @@ class MultipleEmailAddressesVerify(object): self.message = message def __call__(self, form, field): - pattern = re.compile(r"^(?:\s*\S+@([a-z0-9\-]{1,}\.)*([a-z]{1,})[\s|,]*)+$", re.IGNORECASE) + pattern = re.compile(r'^([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{1,})(,([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{2,}))*$', re.IGNORECASE) if not pattern.match(field.data.replace(" ", "")): raise validators.ValidationError(self.message)