From cb5538d958c9695d3e505f8aa73e09efa8d156fc Mon Sep 17 00:00:00 2001 From: Arnaud PAUGET Date: Thu, 21 Apr 2022 16:30:57 +0200 Subject: [PATCH 1/2] fix(19647) : changing the pattern regex in html to prevent validation error AND adding the verification in controller --- src/bundle/auth/Controller/userAccount.php | 5 +++++ .../maarchRM/Resources/view/auth/userAccount/admin/edit.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bundle/auth/Controller/userAccount.php b/src/bundle/auth/Controller/userAccount.php index 6f013bc3f..7cd095a24 100755 --- a/src/bundle/auth/Controller/userAccount.php +++ b/src/bundle/auth/Controller/userAccount.php @@ -223,6 +223,11 @@ class userAccount $userAccount->accountId = \laabs::newId(); $userAccount->accountType = 'user'; + if (!is_null($userAccount->emailAddress) && !filter_var($userAccount->emailAddress, FILTER_VALIDATE_EMAIL)) { + $validationErrors = ["Email adress isn't valid"]; + throw \laabs::newException("auth/invalidUserInformationException", $validationErrors); + } + $organizationController = \laabs::newController('organization/organization'); if (!is_null($organizations)) { $organization = $organizationController->read($organizations[0]); diff --git a/src/presentation/maarchRM/Resources/view/auth/userAccount/admin/edit.html b/src/presentation/maarchRM/Resources/view/auth/userAccount/admin/edit.html index 433a8675c..da2c87173 100755 --- a/src/presentation/maarchRM/Resources/view/auth/userAccount/admin/edit.html +++ b/src/presentation/maarchRM/Resources/view/auth/userAccount/admin/edit.html @@ -279,7 +279,7 @@ } function validateEmail($email) { - var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; + var emailReg = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/; return emailReg.test($email); } -- GitLab From fd26392e3c8aa4ad889c175aca7c64373be8ace7 Mon Sep 17 00:00:00 2001 From: Cyril Vazquez Date: Mon, 25 Apr 2022 12:11:58 +0200 Subject: [PATCH 2/2] Update userAccount.php --- src/bundle/auth/Controller/userAccount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bundle/auth/Controller/userAccount.php b/src/bundle/auth/Controller/userAccount.php index 7cd095a24..e06907335 100755 --- a/src/bundle/auth/Controller/userAccount.php +++ b/src/bundle/auth/Controller/userAccount.php @@ -224,7 +224,7 @@ class userAccount $userAccount->accountType = 'user'; if (!is_null($userAccount->emailAddress) && !filter_var($userAccount->emailAddress, FILTER_VALIDATE_EMAIL)) { - $validationErrors = ["Email adress isn't valid"]; + $validationErrors = ["Email malformed"]; throw \laabs::newException("auth/invalidUserInformationException", $validationErrors); } -- GitLab