From e64c3bc176d928fb4c39bc9c13d6b0283325388d Mon Sep 17 00:00:00 2001 From: natechicago Date: Wed, 16 Mar 2016 21:58:22 -0500 Subject: [PATCH 1/2] [Validator] - Bugfix for 18146 - EmailValidator cannot extract hostname if email contains multiple @ symbols --- .../Validator/Constraints/EmailValidator.php | 2 +- .../Tests/Constraints/EmailValidatorTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index c8c3c5fc720b8..2901d7ee2ff24 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -37,7 +37,7 @@ public function validate($value, Constraint $constraint) $valid = filter_var($value, FILTER_VALIDATE_EMAIL); if ($valid) { - $host = substr($value, strpos($value, '@') + 1); + $host = substr(strrchr($value, '@'), 1); // Check for host DNS resource records if ($valid && $constraint->checkMX) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 10d17b5c68cd4..b2b8dfa07894e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -125,4 +125,19 @@ public function getDnsChecks() array('AAAA', true), ); } + + public function testHostnameIsProperlyParsed() + { + DnsMock::withMockedHosts(array( + 'baz.com' => array(array('type' => 'MX')), + '@bar"@baz.com' => array(array('type' => false)), + )); + + $this->validator->validate( + '"foo@bar"@baz.com', + new Email(array('checkMX' => true)) + ); + + $this->assertNoViolation(); + } } From 451918d19ea4aba350c785ce38412bb4f637a1e2 Mon Sep 17 00:00:00 2001 From: natechicago Date: Thu, 17 Mar 2016 08:27:50 -0500 Subject: [PATCH 2/2] [Validator] - Bugfix for 18146 - EmailValidator cannot extract hostname if email contains multiple @ symbols --- .../Component/Validator/Constraints/EmailValidator.php | 2 +- .../Validator/Tests/Constraints/EmailValidatorTest.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index 2901d7ee2ff24..ec94664efd489 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -37,7 +37,7 @@ public function validate($value, Constraint $constraint) $valid = filter_var($value, FILTER_VALIDATE_EMAIL); if ($valid) { - $host = substr(strrchr($value, '@'), 1); + $host = substr($value, strrpos($value, '@') + 1); // Check for host DNS resource records if ($valid && $constraint->checkMX) { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index b2b8dfa07894e..b2d74bac6516e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -128,10 +128,7 @@ public function getDnsChecks() public function testHostnameIsProperlyParsed() { - DnsMock::withMockedHosts(array( - 'baz.com' => array(array('type' => 'MX')), - '@bar"@baz.com' => array(array('type' => false)), - )); + DnsMock::withMockedHosts(array('baz.com' => array(array('type' => 'MX')))); $this->validator->validate( '"foo@bar"@baz.com', pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy