Skip to content

Commit

Permalink
fixed DNSCheckValidation bug (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
issei-m authored and egulias committed Jun 21, 2016
1 parent e9c46ee commit afde3d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion EmailValidator/Validation/DNSCheckValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function isValid($email, EmailLexer $emailLexer)
// use the input to check DNS if we cannot extract something similar to a domain
$host = $email;
// Arguable pattern to extract the domain. Not aiming to validate the domain nor the email
$pattern = "/^[a-z'0-9]+([._-][a-z'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+)+)+$/";
$pattern = "/^[a-z'0-9]+([+._-][a-z'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+)+)+$/";
if (preg_match($pattern, $email, $result)) {
$host = $this->extractHost($result);
}
Expand Down
15 changes: 13 additions & 2 deletions Tests/EmailValidator/Validation/DNSCheckValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@

class DNSCheckValidationTest extends \PHPUnit_Framework_TestCase
{
public function testValidDNS()
public function validEmailsProvider()
{
return [
["[email protected]"],
["[email protected]"],
];
}

/**
* @dataProvider validEmailsProvider
*/
public function testValidDNS($validEmail)
{
$validation = new DNSCheckValidation();
$this->assertTrue($validation->isValid("[email protected]", new EmailLexer()));
$this->assertTrue($validation->isValid($validEmail, new EmailLexer()));
}

public function testInvalidDNS()
Expand Down

0 comments on commit afde3d3

Please sign in to comment.