Skip to content

Commit

Permalink
bug #14853 [Validator] more strict e-mail validation regex (xabbuh)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabpot committed Jun 23, 2015
2 parents 27e6f48 + 6491033 commit dac1552
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Expand Up @@ -24,8 +24,6 @@
class EmailValidator extends ConstraintValidator
{
/**
* isStrict
*
* @var bool
*/
private $isStrict;
Expand Down Expand Up @@ -73,7 +71,7 @@ public function validate($value, Constraint $constraint)

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)
Expand Down
Expand Up @@ -91,6 +91,7 @@ public function getInvalidEmails()
array('example'),
array('example@'),
array('example@localhost'),
array('foo@example.com bar'),
);
}

Expand Down

1 comment on commit dac1552

@COil
Copy link
Contributor

@COil COil commented on dac1552 Jun 25, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.