FWS in localpart tests and FWS sorrounding '@' as invalid emails

This commit is contained in:
Eduardo Gulias Davis
2014-01-13 00:12:24 +01:00
parent 1a859493ee
commit d6ad6d88d8
3 changed files with 32 additions and 29 deletions
+23 -23
View File
@@ -9,29 +9,29 @@ class EmailLexer extends AbstractLexer
//ASCII values
const C_DEL = 127;
const C_NUL = 0;
const S_AT = 64;//'@';
const S_BACKSLASH = 92;//'\\';
const S_DOT = 46;//'.';
const S_DQUOTE = 34;//'"';
const S_OPENPARENTHESIS = 49;//'(';
const S_CLOSEPARENTHESIS = 261;//')';
const S_OPENBRACKET = 262;//'[';
const S_CLOSEBRACKET = 263;//']';
const S_HYPHEN = 264;//'-';
const S_COLON = 265;//':';
const S_DOUBLECOLON = 266;//'::';
const S_SP = 267;//' ';
const S_HTAB = 268;//"\t";
const S_CR = 269;//"\r";
const S_LF = 270;//"\n";
const S_IPV6TAG = 271;//'IPv6:';
const S_LOWERTHAN = 272;//'<'
const S_GREATERTHAN = 273;//'>'
const S_COMMA = 274;//','
const S_SEMICOLON = 275;//';'
const S_OPENQBRACKET = 276;//'[';
const S_CLOSEQBRACKET = 277;//']';
const S_EMPTY = null;//'';
const S_AT = 64;
const S_BACKSLASH = 92;
const S_DOT = 46;
const S_DQUOTE = 34;
const S_OPENPARENTHESIS = 49;
const S_CLOSEPARENTHESIS = 261;
const S_OPENBRACKET = 262;
const S_CLOSEBRACKET = 263;
const S_HYPHEN = 264;
const S_COLON = 265;
const S_DOUBLECOLON = 266;
const S_SP = 267;
const S_HTAB = 268;
const S_CR = 269;
const S_LF = 270;
const S_IPV6TAG = 271;
const S_LOWERTHAN = 272;
const S_GREATERTHAN = 273;
const S_COMMA = 274;
const S_SEMICOLON = 275;
const S_OPENQBRACKET = 276;
const S_CLOSEQBRACKET = 277;
const S_EMPTY = null;
const GENERIC = 300;
const CRLF = 301;
const INVALID = 302;
+6 -6
View File
@@ -341,7 +341,6 @@ class EmailParser
}
}
}
//Comments
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
$this->parseComments();
}
@@ -356,9 +355,9 @@ class EmailParser
}
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) {
//if ($this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
// $this->warnings[] = EmailValidator::DEPREC_QP;
//}
if ($this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
$this->warnings[] = EmailValidator::DEPREC_QP;
}
if ($this->lexer->isNextToken(EmailLexer::GENERIC)) {
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
}
@@ -444,9 +443,11 @@ class EmailParser
$this->lexer->token['type'] === EmailLexer::CRLF ) {
throw new \InvalidArgumentException("ERR_FWS_CRLF_END");
}
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $this->lexer->token['type'] !== EmailLexer::S_SP) {
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) {
throw new \InvalidArgumentException("ERR_ATEXT_AFTER_CFWS");
}
if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) {
throw new \InvalidArgumentException('ERR_EXPECTING_CTEXT');
}
@@ -456,6 +457,5 @@ class EmailParser
} else {
$this->warnings[] = EmailValidator::CFWS_FWS;
}
}
}
@@ -38,6 +38,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
array('example@faked(fake).co.uk'),
array('fabien+@symfony.com'),
array('инфо@письмо.рф'),
);
}
@@ -60,6 +61,8 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
array('ex\ample@localhost'),
array('example@local\host'),
array('example@localhost.'),
array('user name@example.com'),
array('username@ example . com'),
);
}