Compare commits

...

4 Commits

Author SHA1 Message Date
Eduardo Gulias Davis 65afaf3f2b Change DNS validation to default to true instead of false by @brianfreytag 2014-08-22 01:08:16 +02:00
Eduardo Gulias Davis 82f8514d89 COMMA is not allowed in domain part 2014-08-22 01:05:58 +02:00
Eduardo Gulias Davis 440bc61237 Merge pull request #17 from brianfreytag/remove_dns_requirement
Change DNS validation to default to true instead of false
2014-08-21 23:47:24 +02:00
Brian Freytag a96f0822e0 Change DNS validation to default to true instead of false
There shouldn't be a dependency on the checkDNS() method in order to
validate strict = true. We should only be concerned about the DNS if the
library is specifically told to check DNS, so we default the DNS
variable to true and then set it to false if checkDNS is set to true and
checkDNS() returns false.
2014-08-20 15:05:30 -04:00
4 changed files with 13 additions and 6 deletions
+4 -4
View File
@@ -116,13 +116,13 @@ class EmailLexer extends AbstractLexer
protected function getCatchablePatterns()
{
return array(
'[a-zA-Z_]+[4,6]?',
'[a-zA-Z_]+[46]?',
'[0-9]+',
'\r\n',
'::',
'\s+',
'[\x1-\x1F]+',
'.'
'[\x10-\x1F]+',
'.',
);
}
@@ -149,7 +149,7 @@ class EmailLexer extends AbstractLexer
return $this->charValue[$value];
}
if (preg_match('/[\x1-\x1F]+/', $value)) {
if (preg_match('/[\x10-\x1F]+/', $value)) {
return self::INVALID;
}
@@ -86,7 +86,7 @@ class EmailValidator
return false;
}
$dns = false;
$dns = true;
if ($checkDNS) {
$dns = $this->checkDNS();
}
@@ -235,12 +235,18 @@ class DomainPart extends Parser
protected function checkDomainPartExceptions($prev)
{
if ($this->lexer->token['type'] === EmailLexer::S_COMMA) {
throw new \InvalidArgumentException('ERR_COMMA_IN_DOMAIN');
}
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
throw new \InvalidArgumentException('ERR_CONSECUTIVEATS');
}
if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) {
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
}
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
throw new \InvalidArgumentException('ERR_DOMAINHYPHENEND');
}
@@ -45,7 +45,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getInvalidEmails
*/
public function testAInvalidEmails($email)
public function testInvalidEmails($email)
{
$this->assertFalse($this->validator->isValid($email));
}
@@ -65,6 +65,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
array('username@ example . com'),
array('example@(fake).com'),
array('example@(fake.com'),
array('username@example,com'),
);
}