diff --git a/src/Egulias/EmailValidator/EmailLexer.php b/src/Egulias/EmailValidator/EmailLexer.php index 7056235..2050962 100644 --- a/src/Egulias/EmailValidator/EmailLexer.php +++ b/src/Egulias/EmailValidator/EmailLexer.php @@ -142,7 +142,7 @@ protected function getCatchablePatterns() '[0-9]+', '\r\n', '::', - '\s+', + '\s+?', '[\x10-\x1F]+', '.', ); diff --git a/src/Egulias/EmailValidator/Parser/LocalPart.php b/src/Egulias/EmailValidator/Parser/LocalPart.php index 4db0ea6..2f77164 100644 --- a/src/Egulias/EmailValidator/Parser/LocalPart.php +++ b/src/Egulias/EmailValidator/Parser/LocalPart.php @@ -6,7 +6,6 @@ use Egulias\EmailValidator\EmailValidator; use \InvalidArgumentException; - class LocalPart extends Parser { public function parse($localPart) diff --git a/tests/egulias/Tests/EmailValidator/EmailLexerTest.php b/tests/egulias/Tests/EmailValidator/EmailLexerTest.php index 4af771c..85b82cb 100644 --- a/tests/egulias/Tests/EmailValidator/EmailLexerTest.php +++ b/tests/egulias/Tests/EmailValidator/EmailLexerTest.php @@ -26,6 +26,17 @@ public function testLexerTokens($str, $token) $this->assertEquals($token, $lexer->token['type']); } + public function testLexerParsesMultipleSpaces() + { + $lexer = new EmailLexer(); + $lexer->setInput(' '); + $lexer->moveNext(); + $lexer->moveNext(); + $this->assertEquals(EmailLexer::S_SP, $lexer->token['type']); + $lexer->moveNext(); + $this->assertEquals(EmailLexer::S_SP, $lexer->token['type']); + } + public function testLexerForTab() { $lexer = new EmailLexer(); diff --git a/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php b/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php index e72fde4..6a687c0 100644 --- a/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php +++ b/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php @@ -62,6 +62,8 @@ public function getInvalidEmails() { return array( + array('user name@example.com'), + array('user name@example.com'), array('example.@example.co.uk'), array('example@example@example.co.uk'), array('(test_exampel@example.fr)'),