mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-02 05:27:52 +00:00
@@ -6,6 +6,7 @@ use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\NoLocalPart;
|
||||
use Egulias\EmailValidator\Parser\DomainPart;
|
||||
use Egulias\EmailValidator\Parser\LocalPart;
|
||||
use Egulias\EmailValidator\Warning\EmailTooLong;
|
||||
|
||||
/**
|
||||
* EmailParser
|
||||
@@ -16,7 +17,7 @@ class EmailParser
|
||||
{
|
||||
const EMAIL_MAX_LENGTH = 254;
|
||||
|
||||
protected $warnings = array();
|
||||
protected $warnings;
|
||||
protected $domainPart = '';
|
||||
protected $localPart = '';
|
||||
protected $lexer;
|
||||
@@ -28,6 +29,7 @@ class EmailParser
|
||||
$this->lexer = $lexer;
|
||||
$this->localPartParser = new LocalPart($this->lexer);
|
||||
$this->domainPartParser = new DomainPart($this->lexer);
|
||||
$this->warnings = new \SplObjectStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,8 +61,8 @@ class EmailParser
|
||||
{
|
||||
$localPartWarnings = $this->localPartParser->getWarnings();
|
||||
$domainPartWarnings = $this->domainPartParser->getWarnings();
|
||||
|
||||
$this->warnings = array_merge($localPartWarnings, $domainPartWarnings);
|
||||
|
||||
$this->addLongEmailWarning($this->localPart, $this->domainPart);
|
||||
|
||||
return $this->warnings;
|
||||
@@ -96,7 +98,7 @@ class EmailParser
|
||||
protected function addLongEmailWarning($localPart, $parsedDomainPart)
|
||||
{
|
||||
if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_TOOLONG;
|
||||
$this->warnings[EmailTooLong::CODE] = new EmailTooLong();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
use Egulias\EmailValidator\InvalidEmail;
|
||||
use Egulias\EmailValidator\Warning\NoDNSMXRecord;
|
||||
use Egulias\EmailValidator\Warning\NoDNSRecord;
|
||||
use Egulias\EmailValidator\Warning\DomainLiteral;
|
||||
use Egulias\EmailValidator\Warning\TLD;
|
||||
|
||||
/**
|
||||
* EmailValidator
|
||||
@@ -12,39 +15,9 @@ use Egulias\EmailValidator\InvalidEmail;
|
||||
class EmailValidator
|
||||
{
|
||||
const ERR_DEPREC_REACHED = 151;
|
||||
const ERR_UNOPENEDCOMMENT = 152;
|
||||
const RFC5321_TLD = 9;
|
||||
const RFC5321_TLDNUMERIC = 10;
|
||||
const RFC5321_QUOTEDSTRING = 11;
|
||||
const RFC5321_ADDRESSLITERAL = 12;
|
||||
const RFC5321_IPV6DEPRECATED = 13;
|
||||
const CFWS_COMMENT = 17;
|
||||
const CFWS_FWS = 18;
|
||||
const DEPREC_LOCALPART = 33;
|
||||
const DEPREC_FWS = 34;
|
||||
const DEPREC_QTEXT = 35;
|
||||
const DEPREC_QP = 36;
|
||||
const DEPREC_COMMENT = 37;
|
||||
const DEPREC_CTEXT = 38;
|
||||
const DEPREC_CFWS_NEAR_AT = 49;
|
||||
const RFC5322_LOCAL_TOOLONG = 64;
|
||||
const RFC5322_LABEL_TOOLONG = 63;
|
||||
const RFC5322_DOMAIN = 65;
|
||||
const RFC5322_TOOLONG = 66;
|
||||
const RFC5322_DOMAIN_TOOLONG = 255;
|
||||
const RFC5322_DOMAINLITERAL = 70;
|
||||
const RFC5322_DOMLIT_OBSDTEXT = 71;
|
||||
const RFC5322_IPV6_GRPCOUNT = 72;
|
||||
const RFC5322_IPV6_2X2XCOLON = 73;
|
||||
const RFC5322_IPV6_BADCHAR = 74;
|
||||
const RFC5322_IPV6_MAXGRPS = 75;
|
||||
const RFC5322_IPV6_COLONSTRT = 76;
|
||||
const RFC5322_IPV6_COLONEND = 77;
|
||||
const DNSWARN_NO_MX_RECORD = 5;
|
||||
const DNSWARN_NO_RECORD = 6;
|
||||
|
||||
protected $parser;
|
||||
protected $warnings = array();
|
||||
protected $warnings;
|
||||
protected $error;
|
||||
protected $threshold = 255;
|
||||
|
||||
@@ -72,11 +45,11 @@ class EmailValidator
|
||||
$dns = $this->checkDNS();
|
||||
}
|
||||
|
||||
if ($this->hasWarnings() && ((int) max($this->warnings) > $this->threshold)) {
|
||||
$this->error = self::ERR_DEPREC_REACHED;
|
||||
|
||||
return false;
|
||||
}
|
||||
// if ($this->hasWarnings() && ((int) max($this->warnings) > $this->threshold)) {
|
||||
// $this->error = self::ERR_DEPREC_REACHED;
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return !$strict || (!$this->hasWarnings() && $dns);
|
||||
}
|
||||
@@ -128,25 +101,27 @@ class EmailValidator
|
||||
protected function checkDNS()
|
||||
{
|
||||
$checked = true;
|
||||
$MXresult = checkdnsrr(trim($this->parser->getParsedDomainPart()), 'MX');
|
||||
|
||||
$result = checkdnsrr(trim($this->parser->getParsedDomainPart()), 'MX');
|
||||
|
||||
if (!$result) {
|
||||
$this->warnings[] = self::DNSWARN_NO_RECORD;
|
||||
$checked = false;
|
||||
$this->addTLDWarnings();
|
||||
if (!$MXresult) {
|
||||
$this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord();
|
||||
$Aresult = checkdnsrr(trim($this->parser->getParsedDomainPart()), 'A');
|
||||
if (!$Aresult) {
|
||||
$this->warnings[NoDNSRecord::CODE] = new NoDNSRecord();
|
||||
$checked = false;
|
||||
$this->addTLDWarnings();
|
||||
}
|
||||
}
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
protected function addTLDWarnings()
|
||||
{
|
||||
if (!in_array(self::DNSWARN_NO_RECORD, $this->warnings) &&
|
||||
!in_array(self::DNSWARN_NO_MX_RECORD, $this->warnings) &&
|
||||
in_array(self::RFC5322_DOMAINLITERAL, $this->warnings)
|
||||
if (!isset($this->warnings[NoDNSMXRecord::CODE]) &&
|
||||
!isset($this->warnings[NoDNSRecord::CODE]) &&
|
||||
isset($this->warnings[DomainLiteral::CODE])
|
||||
) {
|
||||
$this->warnings[] = self::RFC5321_TLD;
|
||||
$this->warnings[TLD::CODE] = new TLD();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,20 @@ use Egulias\EmailValidator\Exception\ExpectingDTEXT;
|
||||
use Egulias\EmailValidator\Exception\NoDomainPart;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Exception\UnopenedComment;
|
||||
use Egulias\EmailValidator\Warning\AddressLiteral;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\DeprecatedComment;
|
||||
use Egulias\EmailValidator\Warning\DomainLiteral;
|
||||
use Egulias\EmailValidator\Warning\DomainTooLong;
|
||||
use Egulias\EmailValidator\Warning\IPV6BadChar;
|
||||
use Egulias\EmailValidator\Warning\IPV6ColonEnd;
|
||||
use Egulias\EmailValidator\Warning\IPV6ColonStart;
|
||||
use Egulias\EmailValidator\Warning\IPV6Deprecated;
|
||||
use Egulias\EmailValidator\Warning\IPV6DoubleColon;
|
||||
use Egulias\EmailValidator\Warning\IPV6GroupCount;
|
||||
use Egulias\EmailValidator\Warning\IPV6MaxGroups;
|
||||
use Egulias\EmailValidator\Warning\LabelTooLong;
|
||||
use Egulias\EmailValidator\Warning\ObsoleteDTEXT;
|
||||
|
||||
class DomainPart extends Parser
|
||||
{
|
||||
@@ -37,7 +51,7 @@ class DomainPart extends Parser
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->warnings[] = EmailValidator::DEPREC_COMMENT;
|
||||
$this->warnings[DeprecatedComment::CODE] = new DeprecatedComment();
|
||||
$this->parseDomainComments();
|
||||
}
|
||||
|
||||
@@ -53,7 +67,7 @@ class DomainPart extends Parser
|
||||
throw new DomainHyphened();
|
||||
}
|
||||
if ($length > self::DOMAIN_MAX_LENGTH) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_DOMAIN_TOOLONG;
|
||||
$this->warnings[DomainTooLong::CODE] = new DomainTooLong();
|
||||
}
|
||||
if ($prev['type'] === EmailLexer::S_CR) {
|
||||
throw new CRLFAtTheEnd();
|
||||
@@ -70,7 +84,7 @@ class DomainPart extends Parser
|
||||
{
|
||||
$prev = $this->lexer->getPrevious();
|
||||
if ($prev['type'] === EmailLexer::S_COLON) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_COLONEND;
|
||||
$this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd();
|
||||
}
|
||||
|
||||
$IPv6 = substr($addressLiteral, 5);
|
||||
@@ -80,19 +94,19 @@ class DomainPart extends Parser
|
||||
$colons = strpos($IPv6, '::');
|
||||
|
||||
if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_BADCHAR;
|
||||
$this->warnings[IPV6BadChar::CODE] = new IPV6BadChar();
|
||||
}
|
||||
|
||||
if ($colons === false) {
|
||||
// We need exactly the right number of groups
|
||||
if ($groupCount !== $maxGroups) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_GRPCOUNT;
|
||||
$this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($colons !== strrpos($IPv6, '::')) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_2X2XCOLON;
|
||||
$this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,9 +117,9 @@ class DomainPart extends Parser
|
||||
}
|
||||
|
||||
if ($groupCount > $maxGroups) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_MAXGRPS;
|
||||
$this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups();
|
||||
} elseif ($groupCount === $maxGroups) {
|
||||
$this->warnings[] = EmailValidator::RFC5321_IPV6DEPRECATED;
|
||||
$this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,13 +174,13 @@ class DomainPart extends Parser
|
||||
protected function parseDomainLiteral()
|
||||
{
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_COLON)) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_COLONSTRT;
|
||||
$this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart();
|
||||
}
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) {
|
||||
$lexer = clone $this->lexer;
|
||||
$lexer->moveNext();
|
||||
if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_COLONSTRT;
|
||||
$this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +200,7 @@ class DomainPart extends Parser
|
||||
$this->lexer->token['type'] === EmailLexer::C_DEL ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_LF
|
||||
) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_DOMLIT_OBSDTEXT;
|
||||
$this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) {
|
||||
@@ -196,7 +210,7 @@ class DomainPart extends Parser
|
||||
if ($this->lexer->isNextTokenAny(
|
||||
array(EmailLexer::S_HTAB, EmailLexer::S_SP, $this->lexer->token['type'] === EmailLexer::CRLF)
|
||||
)) {
|
||||
$this->warnings[] = EmailValidator::CFWS_FWS;
|
||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||
$this->parseFWS();
|
||||
}
|
||||
|
||||
@@ -205,7 +219,7 @@ class DomainPart extends Parser
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_DOMLIT_OBSDTEXT;
|
||||
$this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT();
|
||||
$addressLiteral .= $this->lexer->token['value'];
|
||||
$this->lexer->moveNext();
|
||||
$this->validateQuotedPair();
|
||||
@@ -229,11 +243,11 @@ class DomainPart extends Parser
|
||||
}
|
||||
|
||||
if (!$IPv6TAG) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_DOMAINLITERAL;
|
||||
$this->warnings[DomainLiteral::CODE] = new DomainLiteral();
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
$this->warnings[] = EmailValidator::RFC5321_ADDRESSLITERAL;
|
||||
$this->warnings[AddressLiteral::CODE] = new AddressLiteral();
|
||||
|
||||
$this->checkIPV6Tag($addressLiteral);
|
||||
|
||||
@@ -246,14 +260,14 @@ class DomainPart extends Parser
|
||||
|
||||
// Extract IPv4 part from the end of the address-literal (if there is one)
|
||||
if (preg_match(
|
||||
'/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/',
|
||||
$addressLiteral,
|
||||
$matchesIP
|
||||
) > 0
|
||||
'/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/',
|
||||
$addressLiteral,
|
||||
$matchesIP
|
||||
) > 0
|
||||
) {
|
||||
$index = strrpos($addressLiteral, $matchesIP[0]);
|
||||
if ($index === 0) {
|
||||
$this->warnings[] = EmailValidator::RFC5321_ADDRESSLITERAL;
|
||||
$this->warnings[AddressLiteral::CODE] = new AddressLiteral();
|
||||
return false;
|
||||
}
|
||||
// Convert IPv4 part to IPv6 format for further testing
|
||||
@@ -319,7 +333,7 @@ class DomainPart extends Parser
|
||||
$prev['type'] === EmailLexer::GENERIC &&
|
||||
strlen($prev['value']) > 63
|
||||
) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_LABEL_TOOLONG;
|
||||
$this->warnings[LabelTooLong::CODE] = new LabelTooLong();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\UnopenedComment;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\LocalTooLong;
|
||||
|
||||
class LocalPart extends Parser
|
||||
{
|
||||
@@ -58,8 +60,8 @@ class LocalPart extends Parser
|
||||
}
|
||||
|
||||
$prev = $this->lexer->getPrevious();
|
||||
if (strlen($prev['value']) > EmailValidator::RFC5322_LOCAL_TOOLONG) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_LOCAL_TOOLONG;
|
||||
if (strlen($prev['value']) > LocalTooLong::LOCAL_PART_LENGTH) {
|
||||
$this->warnings[LocalTooLong::CODE] = new LocalTooLong();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +87,7 @@ class LocalPart extends Parser
|
||||
while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && $this->lexer->token) {
|
||||
$parseAgain = false;
|
||||
if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) {
|
||||
$this->warnings[] = EmailValidator::CFWS_FWS;
|
||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||
$setSpecialsWarning = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Exception\AtextAfterCFWS;
|
||||
use Egulias\EmailValidator\Exception\ConsecutiveDot;
|
||||
use Egulias\EmailValidator\Exception\CRLFAtTheEnd;
|
||||
@@ -14,10 +13,15 @@ use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\ExpectingCTEXT;
|
||||
use Egulias\EmailValidator\Exception\UnclosedComment;
|
||||
use Egulias\EmailValidator\Exception\UnclosedQuotedString;
|
||||
use Egulias\EmailValidator\Warning\CFWSNearAt;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\Comment;
|
||||
use Egulias\EmailValidator\Warning\QuotedPart;
|
||||
use Egulias\EmailValidator\Warning\QuotedString;
|
||||
|
||||
abstract class Parser
|
||||
{
|
||||
protected $warnings = array();
|
||||
protected $warnings = [];
|
||||
protected $lexer;
|
||||
protected $openedParenthesis = 0;
|
||||
|
||||
@@ -49,14 +53,15 @@ abstract class Parser
|
||||
throw new ExpectedQPair();
|
||||
}
|
||||
|
||||
$this->warnings[] = EmailValidator::DEPREC_QP;
|
||||
$this->warnings[QuotedPart::CODE] =
|
||||
new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']);
|
||||
}
|
||||
|
||||
protected function parseComments()
|
||||
{
|
||||
$this->openedParenthesis = 1;
|
||||
$this->isUnclosedComment();
|
||||
$this->warnings[] = EmailValidator::CFWS_COMMENT;
|
||||
$this->warnings[Comment::CODE] = new Comment();
|
||||
while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) {
|
||||
$this->openedParenthesis++;
|
||||
@@ -71,7 +76,7 @@ abstract class Parser
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_AT)) {
|
||||
$this->warnings[] = EmailValidator::DEPREC_CFWS_NEAR_AT;
|
||||
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,9 +109,9 @@ abstract class Parser
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) {
|
||||
$this->warnings[] = EmailValidator::DEPREC_CFWS_NEAR_AT;
|
||||
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
||||
} else {
|
||||
$this->warnings[] = EmailValidator::CFWS_FWS;
|
||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +168,8 @@ abstract class Parser
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->warnings[] = EmailValidator::DEPREC_QP;
|
||||
$this->warnings[QuotedPart::CODE] =
|
||||
new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']);
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -181,13 +187,13 @@ abstract class Parser
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
$this->warnings[] = EmailValidator::RFC5321_QUOTEDSTRING;
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_DQUOTE);
|
||||
$hasClosingQuote = true;
|
||||
} catch (\Exception $e) {
|
||||
throw new UnclosedQuotedString();
|
||||
}
|
||||
$this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']);
|
||||
|
||||
return $hasClosingQuote;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class AddressLiteral extends Warning
|
||||
{
|
||||
const CODE = 12;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Address literal in domain part';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class CFWSNearAt extends Warning
|
||||
{
|
||||
const CODE = 49;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = "Deprecated folding white space near @";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class CFWSWithFWS extends Warning
|
||||
{
|
||||
const CODE = 18;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Folding whites space followed by folding white space';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class Comment extends Warning
|
||||
{
|
||||
const CODE = 17;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = "Comments found in this email";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class DeprecatedComment extends Warning
|
||||
{
|
||||
const CODE = 37;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Deprecated comments';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class DomainLiteral extends Warning
|
||||
{
|
||||
const CODE = 70;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Domain Literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class DomainTooLong extends Warning
|
||||
{
|
||||
const CODE = 255;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Domain is too long, exceeds 255 chars';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
use Egulias\EmailValidator\EmailParser;
|
||||
|
||||
class EmailTooLong extends Warning
|
||||
{
|
||||
const CODE = 66;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Email is too long, exceeds ' . EmailParser::EMAIL_MAX_LENGTH;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6BadChar extends Warning
|
||||
{
|
||||
const CODE = 74;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Bad char in IPV6 domain literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6ColonEnd extends Warning
|
||||
{
|
||||
const CODE = 77;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = ':: found at the end of the domain literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6ColonStart extends Warning
|
||||
{
|
||||
const CODE = 76;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = ':: found at the start of the domain literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6Deprecated extends Warning
|
||||
{
|
||||
const CODE = 13;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Deprecated form of IPV6';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6DoubleColon extends Warning
|
||||
{
|
||||
const CODE = 73;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Double colon found after IPV6 tag';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6GroupCount extends Warning
|
||||
{
|
||||
const CODE = 72;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Group count is not IPV6 valid';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6MaxGroups extends Warning
|
||||
{
|
||||
const CODE = 75;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Reached the maximum number of IPV6 groups allowed';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class LabelTooLong extends Warning
|
||||
{
|
||||
const CODE = 63;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Label too long';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class LocalTooLong extends Warning
|
||||
{
|
||||
const CODE = 64;
|
||||
const LOCAL_PART_LENGTH = 64;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Local part is too long, exceeds 64 chars (octets)';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class NoDNSMXRecord extends Warning
|
||||
{
|
||||
const CODE = 6;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'No MX DSN record was found for this email';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class NoDNSRecord extends Warning
|
||||
{
|
||||
const CODE = 5;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'No MX or A DSN record was found for this email';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class ObsoleteDTEXT extends Warning
|
||||
{
|
||||
const CODE = 71;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->rfcNumber = 5322;
|
||||
$this->message = 'Obsolete DTEXT in domain literal';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class QuotedPart extends Warning
|
||||
{
|
||||
const CODE = 36;
|
||||
|
||||
public function __construct($prevToken, $postToken)
|
||||
{
|
||||
$this->message = "Deprecated Quoted String found between $prevToken and $postToken";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class QuotedString extends Warning
|
||||
{
|
||||
const CODE = 11;
|
||||
|
||||
public function __construct($prevToken, $postToken)
|
||||
{
|
||||
$this->message = "Quoted String found between $prevToken and $postToken";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class TLD extends Warning
|
||||
{
|
||||
const CODE = 9;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = "RFC5321, TLD";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
abstract class Warning
|
||||
{
|
||||
const CODE = 0;
|
||||
protected $message;
|
||||
protected $rfcNumber;
|
||||
|
||||
public function message()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function code()
|
||||
{
|
||||
return self::CODE;
|
||||
}
|
||||
|
||||
public function RFCNumber()
|
||||
{
|
||||
return $this->rfcNumber;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,25 @@ use Egulias\EmailValidator\Exception\NoLocalPart;
|
||||
use Egulias\EmailValidator\Exception\UnclosedComment;
|
||||
use Egulias\EmailValidator\Exception\UnclosedQuotedString;
|
||||
use Egulias\EmailValidator\Exception\UnopenedComment;
|
||||
use Egulias\EmailValidator\Warning\AddressLiteral;
|
||||
use Egulias\EmailValidator\Warning\CFWSNearAt;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\Comment;
|
||||
use Egulias\EmailValidator\Warning\DomainLiteral;
|
||||
use Egulias\EmailValidator\Warning\DomainTooLong;
|
||||
use Egulias\EmailValidator\Warning\IPV6BadChar;
|
||||
use Egulias\EmailValidator\Warning\IPV6ColonEnd;
|
||||
use Egulias\EmailValidator\Warning\IPV6ColonStart;
|
||||
use Egulias\EmailValidator\Warning\IPV6Deprecated;
|
||||
use Egulias\EmailValidator\Warning\IPV6DoubleColon;
|
||||
use Egulias\EmailValidator\Warning\IPV6GroupCount;
|
||||
use Egulias\EmailValidator\Warning\IPV6MaxGroups;
|
||||
use Egulias\EmailValidator\Warning\LabelTooLong;
|
||||
use Egulias\EmailValidator\Warning\LocalTooLong;
|
||||
use Egulias\EmailValidator\Warning\NoDNSMXRecord;
|
||||
use Egulias\EmailValidator\Warning\NoDNSRecord;
|
||||
use Egulias\EmailValidator\Warning\ObsoleteDTEXT;
|
||||
use Egulias\EmailValidator\Warning\QuotedString;
|
||||
|
||||
class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -188,203 +207,139 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @dataProvider getInvalidEmailsWithWarnings
|
||||
*/
|
||||
public function testValidEmailsWithWarningsCheck($warnings, $email)
|
||||
public function testInvalidEmailsWithWarningsCheck($expectedWarnings, $email)
|
||||
{
|
||||
$this->assertTrue($this->validator->isValid($email, true));
|
||||
$warnings = $this->validator->getWarnings();
|
||||
$this->assertTrue(
|
||||
count($warnings) === count($expectedWarnings),
|
||||
"Expected: " . implode(",", $expectedWarnings) . " and got " . implode(",", $warnings)
|
||||
);
|
||||
|
||||
$this->assertEquals($warnings, $this->validator->getWarnings());
|
||||
foreach ($warnings as $warning) {
|
||||
$this->assertTrue(isset($expectedWarnings[$warning->code()]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidEmailsWithWarnings
|
||||
*/
|
||||
public function testInvalidEmailsWithDnsCheckAndStrictMode($warnings, $email)
|
||||
public function testInvalidEmailsWithDnsCheckAndStrictMode($expectedWarnings, $email)
|
||||
{
|
||||
$this->assertFalse($this->validator->isValid($email, true, true));
|
||||
|
||||
$this->assertEquals($warnings, $this->validator->getWarnings());
|
||||
$warnings = $this->validator->getWarnings();
|
||||
$this->assertTrue(
|
||||
count($warnings) === count($expectedWarnings),
|
||||
"Expected: " . implode(",", $expectedWarnings) . " and got " . implode(",", $warnings)
|
||||
);
|
||||
|
||||
foreach ($warnings as $warning) {
|
||||
$this->assertTrue(isset($expectedWarnings[$warning->code()]));
|
||||
}
|
||||
}
|
||||
|
||||
public function getInvalidEmailsWithWarnings()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
EmailValidator::DNSWARN_NO_RECORD
|
||||
),
|
||||
'example @example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
EmailValidator::DNSWARN_NO_RECORD
|
||||
),
|
||||
'example@ example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::CFWS_COMMENT,
|
||||
EmailValidator::DNSWARN_NO_RECORD
|
||||
),
|
||||
'example@example(examplecomment).co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::CFWS_COMMENT,
|
||||
EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example(examplecomment)@example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_QUOTEDSTRING,
|
||||
EmailValidator::CFWS_FWS,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
"\"\t\"@example.co.uk"
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_QUOTEDSTRING,
|
||||
EmailValidator::CFWS_FWS,
|
||||
EmailValidator::DNSWARN_NO_RECORD
|
||||
),
|
||||
"\"\r\"@example.co.uk"
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
[
|
||||
[CFWSNearAt::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example @invalid.example.com'
|
||||
],
|
||||
[
|
||||
[CFWSNearAt::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@ invalid.example.com'
|
||||
],
|
||||
[
|
||||
[Comment::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@invalid.example(examplecomment).com'
|
||||
],
|
||||
[
|
||||
[Comment::CODE, CFWSNearAt::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example(examplecomment)@invalid.example.com'
|
||||
],
|
||||
[
|
||||
[QuotedString::CODE, CFWSWithFWS::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
"\"\t\"@invalid.example.com"
|
||||
],
|
||||
[
|
||||
[QuotedString::CODE, CFWSWithFWS::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
"\"\r\"@invalid.example.com"
|
||||
],
|
||||
[
|
||||
[AddressLiteral::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@[127.0.0.1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[AddressLiteral::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5321_IPV6DEPRECATED,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[AddressLiteral::CODE, IPV6Deprecated::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370::]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_MAXGRPS,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[AddressLiteral::CODE, IPV6MaxGroups::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334::]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_2X2XCOLON,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
|
||||
[AddressLiteral::CODE, IPV6DoubleColon::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@[IPv6:1::1::1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMLIT_OBSDTEXT,
|
||||
EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[ObsoleteDTEXT::CODE, DomainLiteral::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
"example@[\n]"
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[DomainLiteral::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@[::1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[DomainLiteral::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@[::123.45.67.178]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_IPV6_COLONSTRT,
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_GRPCOUNT,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[IPV6ColonStart::CODE, AddressLiteral::CODE, IPV6GroupCount::CODE, NoDNSMXRecord::CODE,
|
||||
NoDNSRecord::CODE],
|
||||
'example@[IPv6::2001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_BADCHAR,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[AddressLiteral::CODE, IPV6BadChar::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@[IPv6:z001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_COLONEND,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[AddressLiteral::CODE, IPV6ColonEnd::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_QUOTEDSTRING,
|
||||
EmailValidator::DNSWARN_NO_RECORD
|
||||
),
|
||||
'"example"@example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_LOCAL_TOOLONG,
|
||||
EmailValidator::DNSWARN_NO_RECORD
|
||||
),
|
||||
'too_long_localpart_too_long_localpart_too_long_localpart_too_long_localpart@example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_LABEL_TOOLONG,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[QuotedString::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'"example"@invalid.example.com'
|
||||
],
|
||||
[
|
||||
[LocalTooLong::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'too_long_localpart_too_long_localpart_too_long_localpart_too_long_localpart@invalid.example.com'
|
||||
],
|
||||
[
|
||||
[LabelTooLong::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAIN_TOOLONG,
|
||||
EmailValidator::RFC5322_TOOLONG,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocal'.
|
||||
],
|
||||
[
|
||||
[DomainTooLong::CODE, LabelTooLong::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example2@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocal'.
|
||||
'parttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'.
|
||||
'toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAIN_TOOLONG,
|
||||
EmailValidator::RFC5322_TOOLONG,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[DomainTooLong::CODE, LabelTooLong::CODE, NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocal'.
|
||||
'parttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'.
|
||||
'toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpar'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
],
|
||||
[
|
||||
[NoDNSMXRecord::CODE, NoDNSRecord::CODE],
|
||||
'test@test'
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user