From 2a36c3332516141a9a75c05a472d61fb5faa3adb Mon Sep 17 00:00:00 2001 From: Stanislas Date: Fri, 29 Sep 2023 10:11:48 +0200 Subject: [PATCH] fix(Email): unsanitize email before check validation --- src/UserEmail.php | 4 +++- tests/units/GLPIMailer.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/UserEmail.php b/src/UserEmail.php index c232645b674..75541113a95 100644 --- a/src/UserEmail.php +++ b/src/UserEmail.php @@ -33,6 +33,8 @@ * --------------------------------------------------------------------- */ +use Glpi\Toolbox\Sanitizer; + /** * UserEmail class **/ @@ -274,7 +276,7 @@ public function prepareInputForUpdate($input) */ private function checkInputEmailValidity(array $input): bool { - return isset($input['email']) && !empty($input['email']) && GLPIMailer::validateAddress($input['email']); + return isset($input['email']) && !empty($input['email']) && GLPIMailer::validateAddress(Sanitizer::unsanitize($input['email'])); } diff --git a/tests/units/GLPIMailer.php b/tests/units/GLPIMailer.php index e343cd3e713..67578809cf2 100644 --- a/tests/units/GLPIMailer.php +++ b/tests/units/GLPIMailer.php @@ -67,6 +67,7 @@ protected function valideAddressProvider() ["test@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.dot", true], ["test@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.dot", false], ["test@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", true], + ["abcd'efgh@example.com", true], ]; }