mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-30 12:07:59 +00:00
comments are not allowed in IDLeft for message-id
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Egulias\EmailValidator;
|
||||
use Egulias\EmailValidator\Parser;
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Result\Result;
|
||||
use Egulias\EmailValidator\Parser\LocalPart;
|
||||
use Egulias\EmailValidator\Parser\IDLeftPart;
|
||||
use Egulias\EmailValidator\Parser\IDRightPart;
|
||||
use Egulias\EmailValidator\Result\ValidEmail;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
@@ -61,7 +61,7 @@ class MessageIDParser extends Parser
|
||||
|
||||
private function processIDLeft() : Result
|
||||
{
|
||||
$localPartParser = new LocalPart($this->lexer);
|
||||
$localPartParser = new IDLeftPart($this->lexer);
|
||||
$localPartResult = $localPartParser->parse();
|
||||
$this->idLeft = $localPartParser->localPart();
|
||||
$this->warnings = array_merge($localPartParser->getWarnings(), $this->warnings);
|
||||
|
||||
@@ -133,14 +133,6 @@ class DomainPart extends PartParser
|
||||
return new ValidEmail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDomainPart()
|
||||
{
|
||||
return $this->domainPart;
|
||||
}
|
||||
|
||||
protected function parseComments(): Result
|
||||
{
|
||||
$commentParser = new Comment($this->lexer, new DomainComment());
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\Result\Result;
|
||||
use Egulias\EmailValidator\Parser\LocalPart;
|
||||
use Egulias\EmailValidator\Result\InvalidEmail;
|
||||
use Egulias\EmailValidator\Result\Reason\CommentsInIDRight;
|
||||
|
||||
class IDLeftPart extends LocalPart
|
||||
{
|
||||
protected function parseComments(): Result
|
||||
{
|
||||
return new InvalidEmail(new CommentsInIDRight(), $this->lexer->token['value']);
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class LocalPart extends PartParser
|
||||
return $parseAgain;
|
||||
}
|
||||
|
||||
private function parseComments(): Result
|
||||
protected function parseComments(): Result
|
||||
{
|
||||
$commentParser = new Comment($this->lexer, new LocalComment());
|
||||
$result = $commentParser->parse();
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Result\Reason;
|
||||
|
||||
class CommentsInIDRight implements Reason
|
||||
{
|
||||
public function code() : int
|
||||
{
|
||||
return 400;
|
||||
}
|
||||
|
||||
public function description() : string
|
||||
{
|
||||
return 'Comments are not allowed in IDRight for message-id';
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,20 @@ class MessageIDValidationTest extends TestCase
|
||||
['example@with space'],
|
||||
['example@iana.'],
|
||||
['example@ia\na.'],
|
||||
/**
|
||||
* RFC 2822, section 3.6.4, Page 25
|
||||
* Since the msg-id has
|
||||
* a similar syntax to angle-addr (identical except that comments and
|
||||
* folding white space are not allowed), a good method is to put the
|
||||
* domain name (or a domain literal IP address) of the host on which the
|
||||
* message identifier was created on the right hand side of the "@", and
|
||||
* put a combination of the current absolute date and time along with
|
||||
* some other currently unique (perhaps sequential) identifier available
|
||||
* on the system (for example, a process id number) on the left hand
|
||||
* side.
|
||||
*/
|
||||
['example(comment)@example.com'],
|
||||
["\r\nFWS@example.com"]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user