Skip to content

Commit

Permalink
fix(SW-27151): removes whitespaces from e-Mails
Browse files Browse the repository at this point in the history
Otherwise they are always validated to false.
  • Loading branch information
ennasus4sun authored and mitelg committed Jul 12, 2023
1 parent 2c71ba6 commit a20bc5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion engine/Shopware/Controllers/Backend/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ public function validateEmailAction()
$this->Front()->Plugins()->ViewRenderer()->setNoRender();
$this->Front()->Plugins()->Json()->setRenderer(false);

$emails = explode(',', (string) $this->Request()->getParam('value', ''));
$emails = array_map('trim', explode(',', (string) $this->Request()->getParam('value', '')));

/** @var EmailValidatorInterface $emailValidator */
$emailValidator = $this->container->get(EmailValidator::class);
Expand Down
4 changes: 4 additions & 0 deletions tests/Functional/Controllers/Backend/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ public function provideEmails(): Generator
'emails' => '[email protected],[email protected],[email protected]',
'expectedIsValid' => true,
];
yield '3 mails with whitespaces shall be valid' => [
'emails' => '[email protected] , [email protected] , [email protected]',
'expectedIsValid' => true,
];
yield '3 mail shall be invalid' => [
'emails' => '[email protected],[email protected],[email protected]||test',
'expectedIsValid' => false,
Expand Down

0 comments on commit a20bc5e

Please sign in to comment.