Skip to content

Commit c551bd1

Browse files
natechicagonicolas-grekas
authored andcommitted
[Validator] EmailValidator cannot extract hostname if email contains multiple @ symbols
1 parent 56624e6 commit c551bd1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/Validator/Constraints/EmailValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function validate($value, Constraint $constraint)
3737
$valid = filter_var($value, FILTER_VALIDATE_EMAIL);
3838

3939
if ($valid) {
40-
$host = substr($value, strpos($value, '@') + 1);
40+
$host = substr($value, strrpos($value, '@') + 1);
4141

4242
// Check for host DNS resource records
4343
if ($valid && $constraint->checkMX) {

src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,16 @@ public function getDnsChecks()
125125
array('AAAA', true),
126126
);
127127
}
128+
129+
public function testHostnameIsProperlyParsed()
130+
{
131+
DnsMock::withMockedHosts(array('baz.com' => array(array('type' => 'MX'))));
132+
133+
$this->validator->validate(
134+
'"foo@bar"@baz.com',
135+
new Email(array('checkMX' => true))
136+
);
137+
138+
$this->assertNoViolation();
139+
}
128140
}

0 commit comments

Comments
 (0)
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