diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index 8d3a7c5104..903ce59711 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -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) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 0361333fdc..7e7a5cc70f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -91,6 +91,7 @@ class EmailValidatorTest extends AbstractConstraintValidatorTest array('example'), array('example@'), array('example@localhost'), + array('foo@example.com bar'), ); }