From c81f18a3efb941d8c4d2e025f6183b5c6d697307 Mon Sep 17 00:00:00 2001 From: John Congdon Date: Thu, 1 Apr 2021 11:37:14 -0700 Subject: [PATCH] Reset the label when a S_DOT is encountered. (#297) This will allow multi label domain's to still validate correctly. Reset the label when a S_DOT is encountered. --- src/Parser/DomainPart.php | 2 +- tests/EmailValidator/Validation/RFCValidationDomainPartTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Parser/DomainPart.php b/src/Parser/DomainPart.php index 03f84887..4ca54f2d 100644 --- a/src/Parser/DomainPart.php +++ b/src/Parser/DomainPart.php @@ -280,9 +280,9 @@ private function checkLabelLength(bool $isEndOfDomain = false) : Result { if ($this->lexer->token['type'] === EmailLexer::S_DOT || $isEndOfDomain) { if ($this->isLabelTooLong($this->label)) { - $this->label = ''; return new InvalidEmail(new LabelTooLong(), $this->lexer->token['value']); } + $this->label = ''; } $this->label .= $this->lexer->token['value']; return new ValidEmail(); diff --git a/tests/EmailValidator/Validation/RFCValidationDomainPartTest.php b/tests/EmailValidator/Validation/RFCValidationDomainPartTest.php index b9892982..9a5f7f75 100644 --- a/tests/EmailValidator/Validation/RFCValidationDomainPartTest.php +++ b/tests/EmailValidator/Validation/RFCValidationDomainPartTest.php @@ -76,6 +76,7 @@ public function getValidEmails() ['validipv4@[127.0.0.0]'], ['validipv4@127.0.0.0'], ['withhyphen@domain-exam.com'], + ['valid_long_domain@71846jnrsoj91yfhc18rkbrf90ue3onl8y46js38kae8inz0t1.5a-xdycuau.na49.le.example.com'] ); }