Extracted method for CRLF in FWS

This commit is contained in:
Eduardo Gulias Davis
2014-05-08 13:30:27 +02:00
parent c3f2d33935
commit 46050f9bc8
+13 -8
View File
@@ -371,14 +371,7 @@ class EmailParser
{
$previous = $this->lexer->getPrevious();
if ($this->lexer->token['type'] === EmailLexer::CRLF) {
if ($this->lexer->isNextToken(EmailLexer::CRLF)) {
throw new \InvalidArgumentException("ERR_FWS_CRLF_X2");
}
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
throw new \InvalidArgumentException("ERR_FWS_CRLF_END");
}
}
$this->checkCRLFInFWS();
if ($this->lexer->token['type'] === EmailLexer::S_CR) {
throw new \InvalidArgumentException("ERR_CR_NO_LF");
@@ -462,4 +455,16 @@ class EmailParser
return $hasClosingQuote;
}
private function checkCRLFInFWS()
{
if ($this->lexer->token['type'] !== EmailLexer::CRLF) {
return;
}
if ($this->lexer->isNextToken(EmailLexer::CRLF)) {
throw new \InvalidArgumentException("ERR_FWS_CRLF_X2");
}
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
throw new \InvalidArgumentException("ERR_FWS_CRLF_END");
}
}
}