diff --git a/src/Parser/DomainPart.php b/src/Parser/DomainPart.php index 0613e31..8dba7f1 100644 --- a/src/Parser/DomainPart.php +++ b/src/Parser/DomainPart.php @@ -198,6 +198,9 @@ protected function doParseDomainPart() $domain .= $this->lexer->token['value']; $this->lexer->moveNext(); + if ($this->lexer->token['type'] === EmailLexer::S_SP) { + throw new CharNotAllowed(); + } } while (null !== $this->lexer->token['type']); return $domain; diff --git a/tests/EmailValidator/Validation/RFCValidationTest.php b/tests/EmailValidator/Validation/RFCValidationTest.php index 4e72e9e..6a56ef3 100644 --- a/tests/EmailValidator/Validation/RFCValidationTest.php +++ b/tests/EmailValidator/Validation/RFCValidationTest.php @@ -167,6 +167,7 @@ public function getInvalidEmails() ['test@email<'], ['test@email{'], ['test@ '], + ['test@example.com []'], ]; }