mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-30 20:18:04 +00:00
Improving dquote parsing. First refactor to internal function
This commit is contained in:
@@ -29,8 +29,7 @@ class LocalPart extends Parser
|
||||
return new InvalidEmail(new DotAtStart(), $this->lexer->token['value']);
|
||||
}
|
||||
|
||||
$closingQuote = $this->checkDQUOTE($closingQuote);
|
||||
if ($closingQuote && $parseDQuote) {
|
||||
if ($parseDQuote) {
|
||||
$parseDQuote = $this->parseDoubleQuote();
|
||||
}
|
||||
|
||||
@@ -83,6 +82,10 @@ class LocalPart extends Parser
|
||||
*/
|
||||
protected function parseDoubleQuote()
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) {
|
||||
return true;
|
||||
}
|
||||
if(!$this->checkDQUOTE(false)) return false;
|
||||
$parseAgain = true;
|
||||
$special = array(
|
||||
EmailLexer::S_CR => true,
|
||||
|
||||
@@ -220,8 +220,9 @@ abstract class Parser
|
||||
}
|
||||
$previous = $this->lexer->getPrevious();
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) {
|
||||
return new InvalidEmail(new ReasonExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token['value']);
|
||||
// throw new ExpectingATEXT();
|
||||
//https://tools.ietf.org/html/rfc5322#section-3.2.4 - quoted string should be a unit
|
||||
//return new InvalidEmail(new ReasonExpectingATEXT("Expecting ATEXT between DQUOTE"), $this->lexer->token['value']);
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user