mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-11 10:36:45 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 128cc721d7 |
@@ -41,21 +41,7 @@ class DomainPart extends Parser
|
|||||||
{
|
{
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT) {
|
$this->performDomainStartChecks();
|
||||||
throw new DotAtStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_EMPTY) {
|
|
||||||
throw new NoDomainPart();
|
|
||||||
}
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) {
|
|
||||||
throw new DomainHyphened();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
|
||||||
$this->warnings[DeprecatedComment::CODE] = new DeprecatedComment();
|
|
||||||
$this->parseDomainComments();
|
|
||||||
}
|
|
||||||
|
|
||||||
$domain = $this->doParseDomainPart();
|
$domain = $this->doParseDomainPart();
|
||||||
|
|
||||||
@@ -77,6 +63,38 @@ class DomainPart extends Parser
|
|||||||
$this->domainPart = $domain;
|
$this->domainPart = $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function performDomainStartChecks()
|
||||||
|
{
|
||||||
|
$this->checkInvalidTokensAfterAT();
|
||||||
|
$this->checkEmptyDomain();
|
||||||
|
|
||||||
|
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||||
|
$this->warnings[DeprecatedComment::CODE] = new DeprecatedComment();
|
||||||
|
$this->parseDomainComments();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkEmptyDomain()
|
||||||
|
{
|
||||||
|
$thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY ||
|
||||||
|
($this->lexer->token['type'] === EmailLexer::S_SP &&
|
||||||
|
!$this->lexer->isNextToken(EmailLexer::GENERIC));
|
||||||
|
|
||||||
|
if ($thereIsNoDomain) {
|
||||||
|
throw new NoDomainPart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkInvalidTokensAfterAT()
|
||||||
|
{
|
||||||
|
if ($this->lexer->token['type'] === EmailLexer::S_DOT) {
|
||||||
|
throw new DotAtStart();
|
||||||
|
}
|
||||||
|
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) {
|
||||||
|
throw new DomainHyphened();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getDomainPart()
|
public function getDomainPart()
|
||||||
{
|
{
|
||||||
return $this->domainPart;
|
return $this->domainPart;
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ class RFCValidationTest extends TestCase
|
|||||||
['test@email>'],
|
['test@email>'],
|
||||||
['test@email<'],
|
['test@email<'],
|
||||||
['test@email{'],
|
['test@email{'],
|
||||||
|
['test@ '],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user