Skip to content

Commit

Permalink
fix(Email): unsanitize email before check validation
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz authored Sep 29, 2023
1 parent cbdc8ef commit 2a36c33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/UserEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* ---------------------------------------------------------------------
*/

use Glpi\Toolbox\Sanitizer;

/**
* UserEmail class
**/
Expand Down Expand Up @@ -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']));
}


Expand Down
1 change: 1 addition & 0 deletions tests/units/GLPIMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ protected function valideAddressProvider()
["test@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.dot", true],
["test@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.dot", false],
["test@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", true],
["abcd'efgh@example.com", true],
];
}

Expand Down

0 comments on commit 2a36c33

Please sign in to comment.