From 2483fffbb145592b09f36b94a9066552ef5dd34b Mon Sep 17 00:00:00 2001 From: barbara oliveira Date: Fri, 30 Aug 2024 15:50:59 +0200 Subject: [PATCH] Optimize the regex for better performance --- .../decidim/friendly_signup/registration_form_override.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/forms/concerns/decidim/friendly_signup/registration_form_override.rb b/app/forms/concerns/decidim/friendly_signup/registration_form_override.rb index 6dc0f3b..c86e8d4 100644 --- a/app/forms/concerns/decidim/friendly_signup/registration_form_override.rb +++ b/app/forms/concerns/decidim/friendly_signup/registration_form_override.rb @@ -7,8 +7,9 @@ class RegistrationFormOverride < Decidim::RegistrationForm private + EMAIL_REGEX = /\A[^<>"']+@[a-zA-Z0-9\-.]+\.[a-zA-Z]{2,}/ def no_special_characters_in_email - errors.add(:email, :invalid) if email =~ /[<>'"]/ + errors.add(:email, :invalid) if email =~ EMAIL_REGEX end end end