mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-11 10:36:45 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 65afaf3f2b | |||
| 82f8514d89 | |||
| 440bc61237 | |||
| a96f0822e0 |
@@ -116,13 +116,13 @@ class EmailLexer extends AbstractLexer
|
|||||||
protected function getCatchablePatterns()
|
protected function getCatchablePatterns()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'[a-zA-Z_]+[4,6]?',
|
'[a-zA-Z_]+[46]?',
|
||||||
'[0-9]+',
|
'[0-9]+',
|
||||||
'\r\n',
|
'\r\n',
|
||||||
'::',
|
'::',
|
||||||
'\s+',
|
'\s+',
|
||||||
'[\x1-\x1F]+',
|
'[\x10-\x1F]+',
|
||||||
'.'
|
'.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ class EmailLexer extends AbstractLexer
|
|||||||
return $this->charValue[$value];
|
return $this->charValue[$value];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/[\x1-\x1F]+/', $value)) {
|
if (preg_match('/[\x10-\x1F]+/', $value)) {
|
||||||
return self::INVALID;
|
return self::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class EmailValidator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dns = false;
|
$dns = true;
|
||||||
if ($checkDNS) {
|
if ($checkDNS) {
|
||||||
$dns = $this->checkDNS();
|
$dns = $this->checkDNS();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,12 +235,18 @@ class DomainPart extends Parser
|
|||||||
|
|
||||||
protected function checkDomainPartExceptions($prev)
|
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) {
|
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
||||||
throw new \InvalidArgumentException('ERR_CONSECUTIVEATS');
|
throw new \InvalidArgumentException('ERR_CONSECUTIVEATS');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) {
|
if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) {
|
||||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||||
throw new \InvalidArgumentException('ERR_DOMAINHYPHENEND');
|
throw new \InvalidArgumentException('ERR_DOMAINHYPHENEND');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider getInvalidEmails
|
* @dataProvider getInvalidEmails
|
||||||
*/
|
*/
|
||||||
public function testAInvalidEmails($email)
|
public function testInvalidEmails($email)
|
||||||
{
|
{
|
||||||
$this->assertFalse($this->validator->isValid($email));
|
$this->assertFalse($this->validator->isValid($email));
|
||||||
}
|
}
|
||||||
@@ -65,6 +65,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('username@ example . com'),
|
array('username@ example . com'),
|
||||||
array('example@(fake).com'),
|
array('example@(fake).com'),
|
||||||
array('example@(fake.com'),
|
array('example@(fake.com'),
|
||||||
|
array('username@example,com'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user