From a20bc5ec063780bc5b8bb6ed22dbed3d4920b463 Mon Sep 17 00:00:00 2001 From: Susanne Hartung Date: Tue, 11 Jul 2023 08:39:47 +0200 Subject: [PATCH] fix(SW-27151): removes whitespaces from e-Mails Otherwise they are always validated to false. --- engine/Shopware/Controllers/Backend/Base.php | 2 +- tests/Functional/Controllers/Backend/BaseTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/Shopware/Controllers/Backend/Base.php b/engine/Shopware/Controllers/Backend/Base.php index f4d977b1b37..ff4a4522259 100644 --- a/engine/Shopware/Controllers/Backend/Base.php +++ b/engine/Shopware/Controllers/Backend/Base.php @@ -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); diff --git a/tests/Functional/Controllers/Backend/BaseTest.php b/tests/Functional/Controllers/Backend/BaseTest.php index 67949b84a2a..5e75b5a1e79 100644 --- a/tests/Functional/Controllers/Backend/BaseTest.php +++ b/tests/Functional/Controllers/Backend/BaseTest.php @@ -246,6 +246,10 @@ public function provideEmails(): Generator 'emails' => 'email@shopware.com,email2@shopware.com,email3@shopware.com', 'expectedIsValid' => true, ]; + yield '3 mails with whitespaces shall be valid' => [ + 'emails' => 'email@shopware.com , email2@shopware.com , email3@shopware.com', + 'expectedIsValid' => true, + ]; yield '3 mail shall be invalid' => [ 'emails' => 'email@shopware.com,email2@shopware.com,email3@shopware.com||test', 'expectedIsValid' => false,