Improving dquote parsing. First refactor to internal function

This commit is contained in:
Eduardo Gulias Davis
2020-04-30 23:42:45 +02:00
parent 58400a0742
commit ac3f65dbb6
2 changed files with 8 additions and 4 deletions
+5 -2
View File
@@ -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,
+3 -2
View File
@@ -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 {