bug #14853 [Validator] more strict e-mail validation regex (xabbuh)
This PR was merged into the 2.6 branch.
Discussion
----------
[Validator] more strict e-mail validation regex
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #14848
| License | MIT
| Doc PR |
Commits
-------
6491033
[Validator] more strict e-mail validation regex
This commit is contained in:
commit
dac15524ea
@ -24,8 +24,6 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
class EmailValidator extends ConstraintValidator
|
||||
{
|
||||
/**
|
||||
* isStrict
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $isStrict;
|
||||
@ -73,7 +71,7 @@ class EmailValidator extends ConstraintValidator
|
||||
|
||||
return;
|
||||
}
|
||||
} elseif (!preg_match('/.+\@.+\..+/', $value)) {
|
||||
} elseif (!preg_match('/^.+\@\S+\.\S+$/', $value)) {
|
||||
$this->buildViolation($constraint->message)
|
||||
->setParameter('{{ value }}', $this->formatValue($value))
|
||||
->setCode(Email::INVALID_FORMAT_ERROR)
|
||||
|
@ -91,6 +91,7 @@ class EmailValidatorTest extends AbstractConstraintValidatorTest
|
||||
array('example'),
|
||||
array('example@'),
|
||||
array('example@localhost'),
|
||||
array('foo@example.com bar'),
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user