[Validator] EmailValidator cannot extract hostname if email contains multiple @ symbols
This commit is contained in:
parent
56624e6a9d
commit
c551bd17fc
|
@ -37,7 +37,7 @@ class EmailValidator extends ConstraintValidator
|
||||||
$valid = filter_var($value, FILTER_VALIDATE_EMAIL);
|
$valid = filter_var($value, FILTER_VALIDATE_EMAIL);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$host = substr($value, strpos($value, '@') + 1);
|
$host = substr($value, strrpos($value, '@') + 1);
|
||||||
|
|
||||||
// Check for host DNS resource records
|
// Check for host DNS resource records
|
||||||
if ($valid && $constraint->checkMX) {
|
if ($valid && $constraint->checkMX) {
|
||||||
|
|
|
@ -125,4 +125,16 @@ class EmailValidatorTest extends AbstractConstraintValidatorTest
|
||||||
array('AAAA', true),
|
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