bug #18147 [Validator] EmailValidator cannot extract hostname if email contains multiple @ symbols (natechicago)
This PR was squashed before being merged into the 2.3 branch (closes #18147).
Discussion
----------
[Validator] EmailValidator cannot extract hostname if email contains multiple @ symbols
| Q | A
| ------------- | ---
| Branch | 2.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #18146
| License | MIT
| Doc PR | n/a
Commits
-------
c551bd1
[Validator] EmailValidator cannot extract hostname if email contains multiple @ symbols
This commit is contained in:
commit
d2208301ee
|
@ -37,7 +37,7 @@ class EmailValidator extends ConstraintValidator
|
|||
$valid = filter_var($value, FILTER_VALIDATE_EMAIL);
|
||||
|
||||
if ($valid) {
|
||||
$host = substr($value, strpos($value, '@') + 1);
|
||||
$host = substr($value, strrpos($value, '@') + 1);
|
||||
|
||||
// Check for host DNS resource records
|
||||
if ($valid && $constraint->checkMX) {
|
||||
|
|
|
@ -125,4 +125,16 @@ class EmailValidatorTest extends AbstractConstraintValidatorTest
|
|||
array('AAAA', true),
|
||||
);
|
||||
}
|
||||
|
||||
public function testHostnameIsProperlyParsed()
|
||||
{
|
||||
DnsMock::withMockedHosts(array('baz.com' => array(array('type' => 'MX'))));
|
||||
|
||||
$this->validator->validate(
|
||||
'"foo@bar"@baz.com',
|
||||
new Email(array('checkMX' => true))
|
||||
);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue