mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-04 14:38:21 +00:00
Improve domain part controls for non allowed chars. Fix #57 for DQUOTE
This commit is contained in:
@@ -104,9 +104,6 @@ class DomainPart extends Parser
|
||||
{
|
||||
$domain = '';
|
||||
do {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_SEMICOLON) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
}
|
||||
|
||||
$prev = $this->lexer->getPrevious();
|
||||
|
||||
@@ -221,9 +218,6 @@ class DomainPart extends Parser
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $addressLiteral
|
||||
*/
|
||||
protected function checkIPV4Tag($addressLiteral)
|
||||
{
|
||||
$matchesIP = array();
|
||||
@@ -249,6 +243,17 @@ class DomainPart extends Parser
|
||||
|
||||
protected function checkDomainPartExceptions($prev)
|
||||
{
|
||||
$invalidDomainTokens = array(
|
||||
EmailLexer::S_DQUOTE => true,
|
||||
EmailLexer::S_SEMICOLON => true,
|
||||
EmailLexer::S_GREATERTHAN => true,
|
||||
EmailLexer::S_LOWERTHAN => true,
|
||||
);
|
||||
|
||||
if (isset($invalidDomainTokens[$this->lexer->token['type']])) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_COMMA) {
|
||||
throw new \InvalidArgumentException('ERR_COMMA_IN_DOMAIN');
|
||||
}
|
||||
|
||||
@@ -56,6 +56,12 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
array('""@iana.org'),
|
||||
array('"\""@iana.org'),
|
||||
array('müller@möller.de'),
|
||||
array('test@email*'),
|
||||
array('test@email!'),
|
||||
array('test@email&'),
|
||||
array('test@email^'),
|
||||
array('test@email%'),
|
||||
array('test@email$'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,6 +118,10 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
array('test@foo;bar.com'),
|
||||
array('test;123@foobar.com'),
|
||||
array('test@example..com'),
|
||||
array('email.email@email."'),
|
||||
array('test@email>'),
|
||||
array('test@email<'),
|
||||
array('test@email{'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user