diff options
author | dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> | 2020-12-29 17:00:32 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-12-29 18:59:08 +0300 |
commit | d95648cf4c38e13f8d33f74159ea41288d653f64 (patch) | |
tree | 98f40582587e7e834149f2de93686b232d2857ce /egulias | |
parent | f5579b1590571b41b179eab101c505aa287e1c02 (diff) |
Bump swiftmailer/swiftmailer from 6.2.3 to 6.2.4
Bumps [swiftmailer/swiftmailer](https://github.com/swiftmailer/swiftmailer) from 6.2.3 to 6.2.4.
- [Release notes](https://github.com/swiftmailer/swiftmailer/releases)
- [Changelog](https://github.com/swiftmailer/swiftmailer/blob/master/CHANGES)
- [Commits](https://github.com/swiftmailer/swiftmailer/compare/v6.2.3...v6.2.4)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'egulias')
66 files changed, 10 insertions, 2246 deletions
diff --git a/egulias/email-validator/EmailValidator/EmailLexer.php b/egulias/email-validator/EmailValidator/EmailLexer.php deleted file mode 100644 index 44857288..00000000 --- a/egulias/email-validator/EmailValidator/EmailLexer.php +++ /dev/null @@ -1,241 +0,0 @@ -<?php - -namespace Egulias\EmailValidator; - -use Doctrine\Common\Lexer\AbstractLexer; - -class EmailLexer extends AbstractLexer -{ - //ASCII values - const C_DEL = 127; - const C_NUL = 0; - const S_AT = 64; - const S_BACKSLASH = 92; - const S_DOT = 46; - const S_DQUOTE = 34; - const S_OPENPARENTHESIS = 49; - const S_CLOSEPARENTHESIS = 261; - const S_OPENBRACKET = 262; - const S_CLOSEBRACKET = 263; - const S_HYPHEN = 264; - const S_COLON = 265; - const S_DOUBLECOLON = 266; - const S_SP = 267; - const S_HTAB = 268; - const S_CR = 269; - const S_LF = 270; - const S_IPV6TAG = 271; - const S_LOWERTHAN = 272; - const S_GREATERTHAN = 273; - const S_COMMA = 274; - const S_SEMICOLON = 275; - const S_OPENQBRACKET = 276; - const S_CLOSEQBRACKET = 277; - const S_SLASH = 278; - const S_EMPTY = null; - const GENERIC = 300; - const CRLF = 301; - const INVALID = 302; - const ASCII_INVALID_FROM = 127; - const ASCII_INVALID_TO = 199; - - /** - * US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3) - * - * @var array - */ - protected $charValue = array( - '(' => self::S_OPENPARENTHESIS, - ')' => self::S_CLOSEPARENTHESIS, - '<' => self::S_LOWERTHAN, - '>' => self::S_GREATERTHAN, - '[' => self::S_OPENBRACKET, - ']' => self::S_CLOSEBRACKET, - ':' => self::S_COLON, - ';' => self::S_SEMICOLON, - '@' => self::S_AT, - '\\' => self::S_BACKSLASH, - '/' => self::S_SLASH, - ',' => self::S_COMMA, - '.' => self::S_DOT, - '"' => self::S_DQUOTE, - '-' => self::S_HYPHEN, - '::' => self::S_DOUBLECOLON, - ' ' => self::S_SP, - "\t" => self::S_HTAB, - "\r" => self::S_CR, - "\n" => self::S_LF, - "\r\n" => self::CRLF, - 'IPv6' => self::S_IPV6TAG, - '{' => self::S_OPENQBRACKET, - '}' => self::S_CLOSEQBRACKET, - '' => self::S_EMPTY, - '\0' => self::C_NUL, - ); - - protected $hasInvalidTokens = false; - - protected $previous; - - private static $nullToken = [ - 'value' => '', - 'type' => null, - 'position' => 0, - ]; - - public function __construct() - { - $this->previous = $this->token = self::$nullToken; - } - - /** - * @return void - */ - public function reset() - { - $this->hasInvalidTokens = false; - parent::reset(); - $this->previous = $this->token = self::$nullToken; - } - - public function hasInvalidTokens() - { - return $this->hasInvalidTokens; - } - - /** - * @param string $type - * @throws \UnexpectedValueException - * @return boolean - */ - public function find($type) - { - $search = clone $this; - $search->skipUntil($type); - - if (!$search->lookahead) { - throw new \UnexpectedValueException($type . ' not found'); - } - return true; - } - - /** - * getPrevious - * - * @return array token - */ - public function getPrevious() - { - return $this->previous; - } - - /** - * moveNext - * - * @return boolean - */ - public function moveNext() - { - $this->previous = $this->token; - $hasNext = parent::moveNext(); - $this->token = $this->token ?: self::$nullToken; - - return $hasNext; - } - - /** - * Lexical catchable patterns. - * - * @return string[] - */ - protected function getCatchablePatterns() - { - return array( - '[a-zA-Z_]+[46]?', //ASCII and domain literal - '[^\x00-\x7F]', //UTF-8 - '[0-9]+', - '\r\n', - '::', - '\s+?', - '.', - ); - } - - /** - * Lexical non-catchable patterns. - * - * @return string[] - */ - protected function getNonCatchablePatterns() - { - return array('[\xA0-\xff]+'); - } - - /** - * Retrieve token type. Also processes the token value if necessary. - * - * @param string $value - * @throws \InvalidArgumentException - * @return integer - */ - protected function getType(&$value) - { - if ($this->isNullType($value)) { - return self::C_NUL; - } - - if ($this->isValid($value)) { - return $this->charValue[$value]; - } - - if ($this->isUTF8Invalid($value)) { - $this->hasInvalidTokens = true; - return self::INVALID; - } - - return self::GENERIC; - } - - protected function isValid($value) - { - if (isset($this->charValue[$value])) { - return true; - } - - return false; - } - - /** - * @param string $value - * @return bool - */ - protected function isNullType($value) - { - if ($value === "\0") { - return true; - } - - return false; - } - - /** - * @param string $value - * @return bool - */ - protected function isUTF8Invalid($value) - { - if (preg_match('/\p{Cc}+/u', $value)) { - return true; - } - - return false; - } - - /** - * @return string - */ - protected function getModifiers() - { - return 'iu'; - } -} diff --git a/egulias/email-validator/EmailValidator/EmailParser.php b/egulias/email-validator/EmailValidator/EmailParser.php deleted file mode 100644 index 5bf605ac..00000000 --- a/egulias/email-validator/EmailValidator/EmailParser.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php - -namespace Egulias\EmailValidator; - -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 - * - * @author Eduardo Gulias Davis <me@egulias.com> - */ -class EmailParser -{ - const EMAIL_MAX_LENGTH = 254; - - protected $warnings; - protected $domainPart = ''; - protected $localPart = ''; - protected $lexer; - protected $localPartParser; - protected $domainPartParser; - - public function __construct(EmailLexer $lexer) - { - $this->lexer = $lexer; - $this->localPartParser = new LocalPart($this->lexer); - $this->domainPartParser = new DomainPart($this->lexer); - $this->warnings = new \SplObjectStorage(); - } - - /** - * @param string $str - * @return array - */ - public function parse($str) - { - $this->lexer->setInput($str); - - if (!$this->hasAtToken()) { - throw new NoLocalPart(); - } - - - $this->localPartParser->parse($str); - $this->domainPartParser->parse($str); - - $this->setParts($str); - - if ($this->lexer->hasInvalidTokens()) { - throw new ExpectingATEXT(); - } - - return array('local' => $this->localPart, 'domain' => $this->domainPart); - } - - public function getWarnings() - { - $localPartWarnings = $this->localPartParser->getWarnings(); - $domainPartWarnings = $this->domainPartParser->getWarnings(); - $this->warnings = array_merge($localPartWarnings, $domainPartWarnings); - - $this->addLongEmailWarning($this->localPart, $this->domainPart); - - return $this->warnings; - } - - public function getParsedDomainPart() - { - return $this->domainPart; - } - - protected function setParts($email) - { - $parts = explode('@', $email); - $this->domainPart = $this->domainPartParser->getDomainPart(); - $this->localPart = $parts[0]; - } - - protected function hasAtToken() - { - $this->lexer->moveNext(); - $this->lexer->moveNext(); - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - return false; - } - - return true; - } - - /** - * @param string $localPart - * @param string $parsedDomainPart - */ - protected function addLongEmailWarning($localPart, $parsedDomainPart) - { - if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { - $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); - } - } -} diff --git a/egulias/email-validator/EmailValidator/EmailValidator.php b/egulias/email-validator/EmailValidator/EmailValidator.php deleted file mode 100644 index 1c277072..00000000 --- a/egulias/email-validator/EmailValidator/EmailValidator.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -namespace Egulias\EmailValidator; - -use Egulias\EmailValidator\Exception\InvalidEmail; -use Egulias\EmailValidator\Validation\EmailValidation; - -class EmailValidator -{ - /** - * @var EmailLexer - */ - private $lexer; - - /** - * @var array - */ - protected $warnings; - - /** - * @var InvalidEmail - */ - protected $error; - - public function __construct() - { - $this->lexer = new EmailLexer(); - } - - /** - * @param string $email - * @param EmailValidation $emailValidation - * @return bool - */ - public function isValid($email, EmailValidation $emailValidation) - { - $isValid = $emailValidation->isValid($email, $this->lexer); - $this->warnings = $emailValidation->getWarnings(); - $this->error = $emailValidation->getError(); - - return $isValid; - } - - /** - * @return boolean - */ - public function hasWarnings() - { - return !empty($this->warnings); - } - - /** - * @return array - */ - public function getWarnings() - { - return $this->warnings; - } - - /** - * @return InvalidEmail - */ - public function getError() - { - return $this->error; - } -} diff --git a/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php b/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php deleted file mode 100644 index 97f41a2c..00000000 --- a/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class AtextAfterCFWS extends InvalidEmail -{ - const CODE = 133; - const REASON = "ATEXT found after CFWS"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/CRLFAtTheEnd.php b/egulias/email-validator/EmailValidator/Exception/CRLFAtTheEnd.php deleted file mode 100644 index ec23bc71..00000000 --- a/egulias/email-validator/EmailValidator/Exception/CRLFAtTheEnd.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class CRLFAtTheEnd extends InvalidEmail -{ - const CODE = 149; - const REASON = "CRLF at the end"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/CRLFX2.php b/egulias/email-validator/EmailValidator/Exception/CRLFX2.php deleted file mode 100644 index 6bd377ee..00000000 --- a/egulias/email-validator/EmailValidator/Exception/CRLFX2.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class CRLFX2 extends InvalidEmail -{ - const CODE = 148; - const REASON = "Folding whitespace CR LF found twice"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/CRNoLF.php b/egulias/email-validator/EmailValidator/Exception/CRNoLF.php deleted file mode 100644 index 9c9f7394..00000000 --- a/egulias/email-validator/EmailValidator/Exception/CRNoLF.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class CRNoLF extends InvalidEmail -{ - const CODE = 150; - const REASON = "Missing LF after CR"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/CharNotAllowed.php b/egulias/email-validator/EmailValidator/Exception/CharNotAllowed.php deleted file mode 100644 index ea20ce59..00000000 --- a/egulias/email-validator/EmailValidator/Exception/CharNotAllowed.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class CharNotAllowed extends InvalidEmail -{ - const CODE = 201; - const REASON = "Non allowed character in domain"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/CommaInDomain.php b/egulias/email-validator/EmailValidator/Exception/CommaInDomain.php deleted file mode 100644 index e9245d96..00000000 --- a/egulias/email-validator/EmailValidator/Exception/CommaInDomain.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class CommaInDomain extends InvalidEmail -{ - const CODE = 200; - const REASON = "Comma ',' is not allowed in domain part"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/ConsecutiveAt.php b/egulias/email-validator/EmailValidator/Exception/ConsecutiveAt.php deleted file mode 100644 index 165ff57a..00000000 --- a/egulias/email-validator/EmailValidator/Exception/ConsecutiveAt.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class ConsecutiveAt extends InvalidEmail -{ - const CODE = 128; - const REASON = "Consecutive AT"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/ConsecutiveDot.php b/egulias/email-validator/EmailValidator/Exception/ConsecutiveDot.php deleted file mode 100644 index 949af3b5..00000000 --- a/egulias/email-validator/EmailValidator/Exception/ConsecutiveDot.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class ConsecutiveDot extends InvalidEmail -{ - const CODE = 132; - const REASON = "Consecutive DOT"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/DomainHyphened.php b/egulias/email-validator/EmailValidator/Exception/DomainHyphened.php deleted file mode 100644 index 6f586860..00000000 --- a/egulias/email-validator/EmailValidator/Exception/DomainHyphened.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class DomainHyphened extends InvalidEmail -{ - const CODE = 144; - const REASON = "Hyphen found in domain"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/DotAtEnd.php b/egulias/email-validator/EmailValidator/Exception/DotAtEnd.php deleted file mode 100644 index 05ade77d..00000000 --- a/egulias/email-validator/EmailValidator/Exception/DotAtEnd.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class DotAtEnd extends InvalidEmail -{ - const CODE = 142; - const REASON = "Dot at the end"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/DotAtStart.php b/egulias/email-validator/EmailValidator/Exception/DotAtStart.php deleted file mode 100644 index 7772df7f..00000000 --- a/egulias/email-validator/EmailValidator/Exception/DotAtStart.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class DotAtStart extends InvalidEmail -{ - const CODE = 141; - const REASON = "Found DOT at start"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/ExpectingAT.php b/egulias/email-validator/EmailValidator/Exception/ExpectingAT.php deleted file mode 100644 index 36d633c1..00000000 --- a/egulias/email-validator/EmailValidator/Exception/ExpectingAT.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class ExpectingAT extends InvalidEmail -{ - const CODE = 202; - const REASON = "Expecting AT '@' "; -} diff --git a/egulias/email-validator/EmailValidator/Exception/ExpectingATEXT.php b/egulias/email-validator/EmailValidator/Exception/ExpectingATEXT.php deleted file mode 100644 index 095d9db7..00000000 --- a/egulias/email-validator/EmailValidator/Exception/ExpectingATEXT.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class ExpectingATEXT extends InvalidEmail -{ - const CODE = 137; - const REASON = "Expecting ATEXT"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/ExpectingCTEXT.php b/egulias/email-validator/EmailValidator/Exception/ExpectingCTEXT.php deleted file mode 100644 index 63b870a4..00000000 --- a/egulias/email-validator/EmailValidator/Exception/ExpectingCTEXT.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class ExpectingCTEXT extends InvalidEmail -{ - const CODE = 139; - const REASON = "Expecting CTEXT"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/ExpectingDTEXT.php b/egulias/email-validator/EmailValidator/Exception/ExpectingDTEXT.php deleted file mode 100644 index 6a5bb9bf..00000000 --- a/egulias/email-validator/EmailValidator/Exception/ExpectingDTEXT.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class ExpectingDTEXT extends InvalidEmail -{ - const CODE = 129; - const REASON = "Expected DTEXT"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/ExpectingDomainLiteralClose.php b/egulias/email-validator/EmailValidator/Exception/ExpectingDomainLiteralClose.php deleted file mode 100644 index 81aad427..00000000 --- a/egulias/email-validator/EmailValidator/Exception/ExpectingDomainLiteralClose.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class ExpectingDomainLiteralClose extends InvalidEmail -{ - const CODE = 137; - const REASON = "Closing bracket ']' for domain literal not found"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php b/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php deleted file mode 100644 index a738eeb6..00000000 --- a/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class ExpectingQPair extends InvalidEmail -{ - const CODE = 136; - const REASON = "Expecting QPAIR"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php b/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php deleted file mode 100644 index 1c0218e9..00000000 --- a/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -abstract class InvalidEmail extends \InvalidArgumentException -{ - const REASON = "Invalid email"; - const CODE = 0; - - public function __construct() - { - parent::__construct(static::REASON, static::CODE); - } -} diff --git a/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php b/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php deleted file mode 100644 index 0aa5fa78..00000000 --- a/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class NoDNSRecord extends InvalidEmail -{ - const CODE = 5; - const REASON = 'No MX or A DSN record was found for this email'; -} diff --git a/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php b/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php deleted file mode 100644 index 05a2604c..00000000 --- a/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class NoDomainPart extends InvalidEmail -{ - const CODE = 131; - const REASON = "No Domain part"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/NoLocalPart.php b/egulias/email-validator/EmailValidator/Exception/NoLocalPart.php deleted file mode 100644 index 07c14b84..00000000 --- a/egulias/email-validator/EmailValidator/Exception/NoLocalPart.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class NoLocalPart extends InvalidEmail -{ - const CODE = 130; - const REASON = "No local part"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php b/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php deleted file mode 100644 index c87c97ac..00000000 --- a/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class UnclosedComment extends InvalidEmail -{ - const CODE = 146; - const REASON = "No colosing comment token found"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/UnclosedQuotedString.php b/egulias/email-validator/EmailValidator/Exception/UnclosedQuotedString.php deleted file mode 100644 index 730a39dd..00000000 --- a/egulias/email-validator/EmailValidator/Exception/UnclosedQuotedString.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class UnclosedQuotedString extends InvalidEmail -{ - const CODE = 145; - const REASON = "Unclosed quoted string"; -} diff --git a/egulias/email-validator/EmailValidator/Exception/UnopenedComment.php b/egulias/email-validator/EmailValidator/Exception/UnopenedComment.php deleted file mode 100644 index cff12d92..00000000 --- a/egulias/email-validator/EmailValidator/Exception/UnopenedComment.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Exception; - -class UnopenedComment extends InvalidEmail -{ - const CODE = 152; - const REASON = "No opening comment token found"; -} diff --git a/egulias/email-validator/EmailValidator/Parser/DomainPart.php b/egulias/email-validator/EmailValidator/Parser/DomainPart.php deleted file mode 100644 index 8ed240b3..00000000 --- a/egulias/email-validator/EmailValidator/Parser/DomainPart.php +++ /dev/null @@ -1,386 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Parser; - -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\Exception\CharNotAllowed; -use Egulias\EmailValidator\Exception\CommaInDomain; -use Egulias\EmailValidator\Exception\ConsecutiveAt; -use Egulias\EmailValidator\Exception\CRLFAtTheEnd; -use Egulias\EmailValidator\Exception\CRNoLF; -use Egulias\EmailValidator\Exception\DomainHyphened; -use Egulias\EmailValidator\Exception\DotAtEnd; -use Egulias\EmailValidator\Exception\DotAtStart; -use Egulias\EmailValidator\Exception\ExpectingATEXT; -use Egulias\EmailValidator\Exception\ExpectingDomainLiteralClose; -use Egulias\EmailValidator\Exception\ExpectingDTEXT; -use Egulias\EmailValidator\Exception\NoDomainPart; -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; -use Egulias\EmailValidator\Warning\TLD; - -class DomainPart extends Parser -{ - const DOMAIN_MAX_LENGTH = 254; - protected $domainPart = ''; - - public function parse($domainPart) - { - $this->lexer->moveNext(); - - $this->performDomainStartChecks(); - - $domain = $this->doParseDomainPart(); - - $prev = $this->lexer->getPrevious(); - $length = strlen($domain); - - if ($prev['type'] === EmailLexer::S_DOT) { - throw new DotAtEnd(); - } - if ($prev['type'] === EmailLexer::S_HYPHEN) { - throw new DomainHyphened(); - } - if ($length > self::DOMAIN_MAX_LENGTH) { - $this->warnings[DomainTooLong::CODE] = new DomainTooLong(); - } - if ($prev['type'] === EmailLexer::S_CR) { - throw new CRLFAtTheEnd(); - } - $this->domainPart = $domain; - } - - private function performDomainStartChecks() - { - $this->checkInvalidTokensAfterAT(); - $this->checkEmptyDomain(); - - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); - $this->parseDomainComments(); - } - } - - private function checkEmptyDomain() - { - $thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY || - ($this->lexer->token['type'] === EmailLexer::S_SP && - !$this->lexer->isNextToken(EmailLexer::GENERIC)); - - if ($thereIsNoDomain) { - throw new NoDomainPart(); - } - } - - private function checkInvalidTokensAfterAT() - { - if ($this->lexer->token['type'] === EmailLexer::S_DOT) { - throw new DotAtStart(); - } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { - throw new DomainHyphened(); - } - } - - public function getDomainPart() - { - return $this->domainPart; - } - - public function checkIPV6Tag($addressLiteral, $maxGroups = 8) - { - $prev = $this->lexer->getPrevious(); - if ($prev['type'] === EmailLexer::S_COLON) { - $this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd(); - } - - $IPv6 = substr($addressLiteral, 5); - //Daniel Marschall's new IPv6 testing strategy - $matchesIP = explode(':', $IPv6); - $groupCount = count($matchesIP); - $colons = strpos($IPv6, '::'); - - if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) { - $this->warnings[IPV6BadChar::CODE] = new IPV6BadChar(); - } - - if ($colons === false) { - // We need exactly the right number of groups - if ($groupCount !== $maxGroups) { - $this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount(); - } - return; - } - - if ($colons !== strrpos($IPv6, '::')) { - $this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon(); - return; - } - - if ($colons === 0 || $colons === (strlen($IPv6) - 2)) { - // RFC 4291 allows :: at the start or end of an address - //with 7 other groups in addition - ++$maxGroups; - } - - if ($groupCount > $maxGroups) { - $this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups(); - } elseif ($groupCount === $maxGroups) { - $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated(); - } - } - - protected function doParseDomainPart() - { - $domain = ''; - $openedParenthesis = 0; - do { - $prev = $this->lexer->getPrevious(); - - $this->checkNotAllowedChars($this->lexer->token); - - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->parseComments(); - $openedParenthesis += $this->getOpenedParenthesis(); - $this->lexer->moveNext(); - $tmpPrev = $this->lexer->getPrevious(); - if ($tmpPrev['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - $openedParenthesis--; - } - } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - if ($openedParenthesis === 0) { - throw new UnopenedComment(); - } else { - $openedParenthesis--; - } - } - - $this->checkConsecutiveDots(); - $this->checkDomainPartExceptions($prev); - - if ($this->hasBrackets()) { - $this->parseDomainLiteral(); - } - - $this->checkLabelLength($prev); - - if ($this->isFWS()) { - $this->parseFWS(); - } - - $domain .= $this->lexer->token['value']; - $this->lexer->moveNext(); - } while (null !== $this->lexer->token['type']); - - return $domain; - } - - private function checkNotAllowedChars($token) - { - $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; - if (isset($notAllowed[$token['type']])) { - throw new CharNotAllowed(); - } - } - - protected function parseDomainLiteral() - { - if ($this->lexer->isNextToken(EmailLexer::S_COLON)) { - $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[IPV6ColonStart::CODE] = new IPV6ColonStart(); - } - } - - return $this->doParseDomainLiteral(); - } - - protected function doParseDomainLiteral() - { - $IPv6TAG = false; - $addressLiteral = ''; - do { - if ($this->lexer->token['type'] === EmailLexer::C_NUL) { - throw new ExpectingDTEXT(); - } - - if ($this->lexer->token['type'] === EmailLexer::INVALID || - $this->lexer->token['type'] === EmailLexer::C_DEL || - $this->lexer->token['type'] === EmailLexer::S_LF - ) { - $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); - } - - if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) { - throw new ExpectingDTEXT(); - } - - if ($this->lexer->isNextTokenAny( - array(EmailLexer::S_HTAB, EmailLexer::S_SP, $this->lexer->token['type'] === EmailLexer::CRLF) - )) { - $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); - $this->parseFWS(); - } - - if ($this->lexer->isNextToken(EmailLexer::S_CR)) { - throw new CRNoLF(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) { - $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); - $addressLiteral .= $this->lexer->token['value']; - $this->lexer->moveNext(); - $this->validateQuotedPair(); - } - if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) { - $IPv6TAG = true; - } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEQBRACKET) { - break; - } - - $addressLiteral .= $this->lexer->token['value']; - - } while ($this->lexer->moveNext()); - - $addressLiteral = str_replace('[', '', $addressLiteral); - $addressLiteral = $this->checkIPV4Tag($addressLiteral); - - if (false === $addressLiteral) { - return $addressLiteral; - } - - if (!$IPv6TAG) { - $this->warnings[DomainLiteral::CODE] = new DomainLiteral(); - return $addressLiteral; - } - - $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); - - $this->checkIPV6Tag($addressLiteral); - - return $addressLiteral; - } - - protected function checkIPV4Tag($addressLiteral) - { - $matchesIP = array(); - - // 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 - ) { - $index = strrpos($addressLiteral, $matchesIP[0]); - if ($index === 0) { - $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); - return false; - } - // Convert IPv4 part to IPv6 format for further testing - $addressLiteral = substr($addressLiteral, 0, $index) . '0:0'; - } - - return $addressLiteral; - } - - protected function checkDomainPartExceptions($prev) - { - $invalidDomainTokens = array( - EmailLexer::S_DQUOTE => true, - EmailLexer::S_SEMICOLON => true, - EmailLexer::S_GREATERTHAN => true, - EmailLexer::S_LOWERTHAN => true, - ); - - if (isset($invalidDomainTokens[$this->lexer->token['type']])) { - throw new ExpectingATEXT(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_COMMA) { - throw new CommaInDomain(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - throw new ConsecutiveAt(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) { - throw new ExpectingATEXT(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - throw new DomainHyphened(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH - && $this->lexer->isNextToken(EmailLexer::GENERIC)) { - throw new ExpectingATEXT(); - } - } - - protected function hasBrackets() - { - if ($this->lexer->token['type'] !== EmailLexer::S_OPENBRACKET) { - return false; - } - - try { - $this->lexer->find(EmailLexer::S_CLOSEBRACKET); - } catch (\RuntimeException $e) { - throw new ExpectingDomainLiteralClose(); - } - - return true; - } - - protected function checkLabelLength($prev) - { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && - $prev['type'] === EmailLexer::GENERIC && - strlen($prev['value']) > 63 - ) { - $this->warnings[LabelTooLong::CODE] = new LabelTooLong(); - } - } - - protected function parseDomainComments() - { - $this->isUnclosedComment(); - while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { - $this->warnEscaping(); - $this->lexer->moveNext(); - } - - $this->lexer->moveNext(); - if ($this->lexer->isNextToken(EmailLexer::S_DOT)) { - throw new ExpectingATEXT(); - } - } - - protected function addTLDWarnings() - { - if ($this->warnings[DomainLiteral::CODE]) { - $this->warnings[TLD::CODE] = new TLD(); - } - } -} diff --git a/egulias/email-validator/EmailValidator/Parser/LocalPart.php b/egulias/email-validator/EmailValidator/Parser/LocalPart.php deleted file mode 100644 index fa1d17b7..00000000 --- a/egulias/email-validator/EmailValidator/Parser/LocalPart.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Parser; - -use Egulias\EmailValidator\Exception\DotAtEnd; -use Egulias\EmailValidator\Exception\DotAtStart; -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\EmailValidator; -use Egulias\EmailValidator\Exception\ExpectingAT; -use Egulias\EmailValidator\Exception\ExpectingATEXT; -use Egulias\EmailValidator\Exception\UnclosedQuotedString; -use Egulias\EmailValidator\Exception\UnopenedComment; -use Egulias\EmailValidator\Warning\CFWSWithFWS; -use Egulias\EmailValidator\Warning\LocalTooLong; - -class LocalPart extends Parser -{ - public function parse($localPart) - { - $parseDQuote = true; - $closingQuote = false; - $openedParenthesis = 0; - - while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']) { - throw new DotAtStart(); - } - - $closingQuote = $this->checkDQUOTE($closingQuote); - if ($closingQuote && $parseDQuote) { - $parseDQuote = $this->parseDoubleQuote(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->parseComments(); - $openedParenthesis += $this->getOpenedParenthesis(); - } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - if ($openedParenthesis === 0) { - throw new UnopenedComment(); - } else { - $openedParenthesis--; - } - } - - $this->checkConsecutiveDots(); - - if ($this->lexer->token['type'] === EmailLexer::S_DOT && - $this->lexer->isNextToken(EmailLexer::S_AT) - ) { - throw new DotAtEnd(); - } - - $this->warnEscaping(); - $this->isInvalidToken($this->lexer->token, $closingQuote); - - if ($this->isFWS()) { - $this->parseFWS(); - } - - $this->lexer->moveNext(); - } - - $prev = $this->lexer->getPrevious(); - if (strlen($prev['value']) > LocalTooLong::LOCAL_PART_LENGTH) { - $this->warnings[LocalTooLong::CODE] = new LocalTooLong(); - } - } - - protected function parseDoubleQuote() - { - $parseAgain = true; - $special = array( - EmailLexer::S_CR => true, - EmailLexer::S_HTAB => true, - EmailLexer::S_LF => true - ); - - $invalid = array( - EmailLexer::C_NUL => true, - EmailLexer::S_HTAB => true, - EmailLexer::S_CR => true, - EmailLexer::S_LF => true - ); - $setSpecialsWarning = true; - - $this->lexer->moveNext(); - - while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) { - $parseAgain = false; - if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { - $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); - $setSpecialsWarning = false; - } - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { - $this->lexer->moveNext(); - } - - $this->lexer->moveNext(); - - if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) { - throw new ExpectingATEXT(); - } - } - - $prev = $this->lexer->getPrevious(); - - if ($prev['type'] === EmailLexer::S_BACKSLASH) { - if (!$this->checkDQUOTE(false)) { - throw new UnclosedQuotedString(); - } - } - - if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) { - throw new ExpectingAT(); - } - - return $parseAgain; - } - - protected function isInvalidToken($token, $closingQuote) - { - $forbidden = array( - EmailLexer::S_COMMA, - EmailLexer::S_CLOSEBRACKET, - EmailLexer::S_OPENBRACKET, - EmailLexer::S_GREATERTHAN, - EmailLexer::S_LOWERTHAN, - EmailLexer::S_COLON, - EmailLexer::S_SEMICOLON, - EmailLexer::INVALID - ); - - if (in_array($token['type'], $forbidden) && !$closingQuote) { - throw new ExpectingATEXT(); - } - } -} diff --git a/egulias/email-validator/EmailValidator/Parser/Parser.php b/egulias/email-validator/EmailValidator/Parser/Parser.php deleted file mode 100644 index fa7bd44b..00000000 --- a/egulias/email-validator/EmailValidator/Parser/Parser.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Parser; - -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\Exception\AtextAfterCFWS; -use Egulias\EmailValidator\Exception\ConsecutiveDot; -use Egulias\EmailValidator\Exception\CRLFAtTheEnd; -use Egulias\EmailValidator\Exception\CRLFX2; -use Egulias\EmailValidator\Exception\CRNoLF; -use Egulias\EmailValidator\Exception\ExpectingQPair; -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 = []; - protected $lexer; - protected $openedParenthesis = 0; - - public function __construct(EmailLexer $lexer) - { - $this->lexer = $lexer; - } - - public function getWarnings() - { - return $this->warnings; - } - - abstract public function parse($str); - - /** @return int */ - public function getOpenedParenthesis() - { - return $this->openedParenthesis; - } - - /** - * validateQuotedPair - */ - protected function validateQuotedPair() - { - if (!($this->lexer->token['type'] === EmailLexer::INVALID - || $this->lexer->token['type'] === EmailLexer::C_DEL)) { - throw new ExpectingQPair(); - } - - $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); - } - - protected function parseComments() - { - $this->openedParenthesis = 1; - $this->isUnclosedComment(); - $this->warnings[Comment::CODE] = new Comment(); - while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { - if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) { - $this->openedParenthesis++; - } - $this->warnEscaping(); - $this->lexer->moveNext(); - } - - $this->lexer->moveNext(); - if ($this->lexer->isNextTokenAny(array(EmailLexer::GENERIC, EmailLexer::S_EMPTY))) { - throw new ExpectingATEXT(); - } - - if ($this->lexer->isNextToken(EmailLexer::S_AT)) { - $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); - } - } - - protected function isUnclosedComment() - { - try { - $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); - return true; - } catch (\RuntimeException $e) { - throw new UnclosedComment(); - } - } - - protected function parseFWS() - { - $previous = $this->lexer->getPrevious(); - - $this->checkCRLFInFWS(); - - if ($this->lexer->token['type'] === EmailLexer::S_CR) { - throw new CRNoLF(); - } - - if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) { - throw new AtextAfterCFWS(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) { - throw new ExpectingCTEXT(); - } - - if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { - $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); - } else { - $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); - } - } - - protected function checkConsecutiveDots() - { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - throw new ConsecutiveDot(); - } - } - - protected function isFWS() - { - if ($this->escaped()) { - return false; - } - - if ($this->lexer->token['type'] === EmailLexer::S_SP || - $this->lexer->token['type'] === EmailLexer::S_HTAB || - $this->lexer->token['type'] === EmailLexer::S_CR || - $this->lexer->token['type'] === EmailLexer::S_LF || - $this->lexer->token['type'] === EmailLexer::CRLF - ) { - return true; - } - - return false; - } - - protected function escaped() - { - $previous = $this->lexer->getPrevious(); - - if ($previous['type'] === EmailLexer::S_BACKSLASH - && - $this->lexer->token['type'] !== EmailLexer::GENERIC - ) { - return true; - } - - return false; - } - - protected function warnEscaping() - { - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { - return false; - } - - if ($this->lexer->isNextToken(EmailLexer::GENERIC)) { - throw new ExpectingATEXT(); - } - - if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) { - return false; - } - - $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); - return true; - - } - - protected function checkDQUOTE($hasClosingQuote) - { - if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) { - return $hasClosingQuote; - } - if ($hasClosingQuote) { - return $hasClosingQuote; - } - $previous = $this->lexer->getPrevious(); - if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) { - throw new ExpectingATEXT(); - } - - 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; - } - - protected function checkCRLFInFWS() - { - if ($this->lexer->token['type'] !== EmailLexer::CRLF) { - return; - } - - if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - throw new CRLFX2(); - } - - if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - throw new CRLFAtTheEnd(); - } - } -} diff --git a/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php b/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php deleted file mode 100644 index e5c3e5df..00000000 --- a/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation; - -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\Exception\InvalidEmail; -use Egulias\EmailValidator\Warning\NoDNSMXRecord; -use Egulias\EmailValidator\Exception\NoDNSRecord; - -class DNSCheckValidation implements EmailValidation -{ - /** - * @var array - */ - private $warnings = []; - - /** - * @var InvalidEmail - */ - private $error; - - public function __construct() - { - if (!extension_loaded('intl')) { - throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); - } - } - - public function isValid($email, EmailLexer $emailLexer) - { - // use the input to check DNS if we cannot extract something similar to a domain - $host = $email; - - // Arguable pattern to extract the domain. Not aiming to validate the domain nor the email - if (false !== $lastAtPos = strrpos($email, '@')) { - $host = substr($email, $lastAtPos + 1); - } - - return $this->checkDNS($host); - } - - public function getError() - { - return $this->error; - } - - public function getWarnings() - { - return $this->warnings; - } - - protected function checkDNS($host) - { - $variant = INTL_IDNA_VARIANT_2003; - if ( defined('INTL_IDNA_VARIANT_UTS46') ) { - $variant = INTL_IDNA_VARIANT_UTS46; - } - $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.'; - - $Aresult = true; - $MXresult = checkdnsrr($host, 'MX'); - - if (!$MXresult) { - $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); - $Aresult = checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA'); - if (!$Aresult) { - $this->error = new NoDNSRecord(); - } - } - return $MXresult || $Aresult; - } -} diff --git a/egulias/email-validator/EmailValidator/Validation/EmailValidation.php b/egulias/email-validator/EmailValidator/Validation/EmailValidation.php deleted file mode 100644 index d5a015be..00000000 --- a/egulias/email-validator/EmailValidator/Validation/EmailValidation.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation; - -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\Exception\InvalidEmail; -use Egulias\EmailValidator\Warning\Warning; - -interface EmailValidation -{ - /** - * Returns true if the given email is valid. - * - * @param string $email The email you want to validate. - * @param EmailLexer $emailLexer The email lexer. - * - * @return bool - */ - public function isValid($email, EmailLexer $emailLexer); - - /** - * Returns the validation error. - * - * @return InvalidEmail|null - */ - public function getError(); - - /** - * Returns the validation warnings. - * - * @return Warning[] - */ - public function getWarnings(); -} diff --git a/egulias/email-validator/EmailValidator/Validation/Error/RFCWarnings.php b/egulias/email-validator/EmailValidator/Validation/Error/RFCWarnings.php deleted file mode 100644 index 7f2256d6..00000000 --- a/egulias/email-validator/EmailValidator/Validation/Error/RFCWarnings.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation\Error; - -use Egulias\EmailValidator\Exception\InvalidEmail; - -class RFCWarnings extends InvalidEmail -{ - const CODE = 997; - const REASON = 'Warnings were found.'; -} diff --git a/egulias/email-validator/EmailValidator/Validation/Error/SpoofEmail.php b/egulias/email-validator/EmailValidator/Validation/Error/SpoofEmail.php deleted file mode 100644 index 8c92cb5a..00000000 --- a/egulias/email-validator/EmailValidator/Validation/Error/SpoofEmail.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation\Error; - -use Egulias\EmailValidator\Exception\InvalidEmail; - -class SpoofEmail extends InvalidEmail -{ - const CODE = 998; - const REASON = "The email contains mixed UTF8 chars that makes it suspicious"; -} diff --git a/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php b/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php deleted file mode 100644 index 775ad16f..00000000 --- a/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation\Exception; - -use Exception; - -class EmptyValidationList extends \InvalidArgumentException -{ - public function __construct($code = 0, Exception $previous = null) - { - parent::__construct("Empty validation list is not allowed", $code, $previous); - } -} diff --git a/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php b/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php deleted file mode 100644 index d5e87d8c..00000000 --- a/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation; - -use Egulias\EmailValidator\Exception\InvalidEmail; - -class MultipleErrors extends InvalidEmail -{ - const CODE = 999; - const REASON = "Accumulated errors for multiple validations"; - /** - * @var array - */ - private $errors = []; - - public function __construct(array $errors) - { - $this->errors = $errors; - parent::__construct(); - } - - public function getErrors() - { - return $this->errors; - } -} diff --git a/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php b/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php deleted file mode 100644 index ce161ac8..00000000 --- a/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation; - -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\Validation\Exception\EmptyValidationList; - -class MultipleValidationWithAnd implements EmailValidation -{ - /** - * If one of validations gets failure skips all succeeding validation. - * This means MultipleErrors will only contain a single error which first found. - */ - const STOP_ON_ERROR = 0; - - /** - * All of validations will be invoked even if one of them got failure. - * So MultipleErrors will contain all causes. - */ - const ALLOW_ALL_ERRORS = 1; - - /** - * @var EmailValidation[] - */ - private $validations = []; - - /** - * @var array - */ - private $warnings = []; - - /** - * @var MultipleErrors - */ - private $error; - - /** - * @var bool - */ - private $mode; - - /** - * @param EmailValidation[] $validations The validations. - * @param int $mode The validation mode (one of the constants). - */ - public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) - { - if (count($validations) == 0) { - throw new EmptyValidationList(); - } - - $this->validations = $validations; - $this->mode = $mode; - } - - /** - * {@inheritdoc} - */ - public function isValid($email, EmailLexer $emailLexer) - { - $result = true; - $errors = []; - foreach ($this->validations as $validation) { - $emailLexer->reset(); - $validationResult = $validation->isValid($email, $emailLexer); - $result = $result && $validationResult; - $this->warnings = array_merge($this->warnings, $validation->getWarnings()); - $errors = $this->addNewError($validation->getError(), $errors); - - if ($this->shouldStop($result)) { - break; - } - } - - if (!empty($errors)) { - $this->error = new MultipleErrors($errors); - } - - return $result; - } - - private function addNewError($possibleError, array $errors) - { - if (null !== $possibleError) { - $errors[] = $possibleError; - } - - return $errors; - } - - private function shouldStop($result) - { - return !$result && $this->mode === self::STOP_ON_ERROR; - } - - /** - * {@inheritdoc} - */ - public function getError() - { - return $this->error; - } - - /** - * {@inheritdoc} - */ - public function getWarnings() - { - return $this->warnings; - } -} diff --git a/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php b/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php deleted file mode 100644 index e4bf0cc4..00000000 --- a/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation; - -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\Exception\InvalidEmail; -use Egulias\EmailValidator\Validation\Error\RFCWarnings; - -class NoRFCWarningsValidation extends RFCValidation -{ - /** - * @var InvalidEmail - */ - private $error; - - /** - * {@inheritdoc} - */ - public function isValid($email, EmailLexer $emailLexer) - { - if (!parent::isValid($email, $emailLexer)) { - return false; - } - - if (empty($this->getWarnings())) { - return true; - } - - $this->error = new RFCWarnings(); - - return false; - } - - /** - * {@inheritdoc} - */ - public function getError() - { - return $this->error ?: parent::getError(); - } -} diff --git a/egulias/email-validator/EmailValidator/Validation/RFCValidation.php b/egulias/email-validator/EmailValidator/Validation/RFCValidation.php deleted file mode 100644 index c4ffe350..00000000 --- a/egulias/email-validator/EmailValidator/Validation/RFCValidation.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation; - -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\EmailParser; -use Egulias\EmailValidator\Exception\InvalidEmail; - -class RFCValidation implements EmailValidation -{ - /** - * @var EmailParser - */ - private $parser; - - /** - * @var array - */ - private $warnings = []; - - /** - * @var InvalidEmail - */ - private $error; - - public function isValid($email, EmailLexer $emailLexer) - { - $this->parser = new EmailParser($emailLexer); - try { - $this->parser->parse((string)$email); - } catch (InvalidEmail $invalid) { - $this->error = $invalid; - return false; - } - - $this->warnings = $this->parser->getWarnings(); - return true; - } - - public function getError() - { - return $this->error; - } - - public function getWarnings() - { - return $this->warnings; - } -} diff --git a/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php b/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php deleted file mode 100644 index 4721f0d8..00000000 --- a/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Validation; - -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\Exception\InvalidEmail; -use Egulias\EmailValidator\Validation\Error\SpoofEmail; -use \Spoofchecker; - -class SpoofCheckValidation implements EmailValidation -{ - /** - * @var InvalidEmail - */ - private $error; - - public function __construct() - { - if (!extension_loaded('intl')) { - throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); - } - } - - public function isValid($email, EmailLexer $emailLexer) - { - $checker = new Spoofchecker(); - $checker->setChecks(Spoofchecker::SINGLE_SCRIPT); - - if ($checker->isSuspicious($email)) { - $this->error = new SpoofEmail(); - } - - return $this->error === null; - } - - public function getError() - { - return $this->error; - } - - public function getWarnings() - { - return []; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php b/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php deleted file mode 100644 index 77e70f7f..00000000 --- a/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php b/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php deleted file mode 100644 index be43bbe6..00000000 --- a/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Warning; - -class CFWSNearAt extends Warning -{ - const CODE = 49; - - public function __construct() - { - $this->message = "Deprecated folding white space near @"; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php b/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php deleted file mode 100644 index dea3450e..00000000 --- a/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php +++ /dev/null @@ -1,13 +0,0 @@ -<?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'; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/Comment.php b/egulias/email-validator/EmailValidator/Warning/Comment.php deleted file mode 100644 index 704c2908..00000000 --- a/egulias/email-validator/EmailValidator/Warning/Comment.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Warning; - -class Comment extends Warning -{ - const CODE = 17; - - public function __construct() - { - $this->message = "Comments found in this email"; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php b/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php deleted file mode 100644 index ad43bd7c..00000000 --- a/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Warning; - -class DeprecatedComment extends Warning -{ - const CODE = 37; - - public function __construct() - { - $this->message = 'Deprecated comments'; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php b/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php deleted file mode 100644 index 6f36b5e2..00000000 --- a/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Warning; - -class DomainLiteral extends Warning -{ - const CODE = 70; - - public function __construct() - { - $this->message = 'Domain Literal'; - $this->rfcNumber = 5322; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php b/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php deleted file mode 100644 index 61ff17a7..00000000 --- a/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php b/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php deleted file mode 100644 index 497309db..00000000 --- a/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php +++ /dev/null @@ -1,15 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php b/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php deleted file mode 100644 index ba2fcc01..00000000 --- a/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php b/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php deleted file mode 100644 index 41afa78c..00000000 --- a/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php b/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php deleted file mode 100644 index 1bf754e3..00000000 --- a/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php b/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php deleted file mode 100644 index d752caaa..00000000 --- a/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Warning; - -class IPV6Deprecated extends Warning -{ - const CODE = 13; - - public function __construct() - { - $this->message = 'Deprecated form of IPV6'; - $this->rfcNumber = 5321; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php b/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php deleted file mode 100644 index 4f823949..00000000 --- a/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php b/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php deleted file mode 100644 index a59d317f..00000000 --- a/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php b/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php deleted file mode 100644 index 936274c1..00000000 --- a/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php b/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php deleted file mode 100644 index daf07f40..00000000 --- a/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Warning; - -class LabelTooLong extends Warning -{ - const CODE = 63; - - public function __construct() - { - $this->message = 'Label too long'; - $this->rfcNumber = 5322; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php b/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php deleted file mode 100644 index 0d08d8b3..00000000 --- a/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php +++ /dev/null @@ -1,15 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php b/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php deleted file mode 100644 index b3c21a1f..00000000 --- a/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php b/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php deleted file mode 100644 index 10f19e33..00000000 --- a/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php +++ /dev/null @@ -1,14 +0,0 @@ -<?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'; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/QuotedPart.php b/egulias/email-validator/EmailValidator/Warning/QuotedPart.php deleted file mode 100644 index 7be9e6a3..00000000 --- a/egulias/email-validator/EmailValidator/Warning/QuotedPart.php +++ /dev/null @@ -1,13 +0,0 @@ -<?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"; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/QuotedString.php b/egulias/email-validator/EmailValidator/Warning/QuotedString.php deleted file mode 100644 index e9d56e1e..00000000 --- a/egulias/email-validator/EmailValidator/Warning/QuotedString.php +++ /dev/null @@ -1,13 +0,0 @@ -<?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"; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/TLD.php b/egulias/email-validator/EmailValidator/Warning/TLD.php deleted file mode 100644 index 2338b9f4..00000000 --- a/egulias/email-validator/EmailValidator/Warning/TLD.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace Egulias\EmailValidator\Warning; - -class TLD extends Warning -{ - const CODE = 9; - - public function __construct() - { - $this->message = "RFC5321, TLD"; - } -} diff --git a/egulias/email-validator/EmailValidator/Warning/Warning.php b/egulias/email-validator/EmailValidator/Warning/Warning.php deleted file mode 100644 index ec6a365f..00000000 --- a/egulias/email-validator/EmailValidator/Warning/Warning.php +++ /dev/null @@ -1,30 +0,0 @@ -<?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; - } -} diff --git a/egulias/email-validator/README.md b/egulias/email-validator/README.md deleted file mode 100644 index b5b0d85f..00000000 --- a/egulias/email-validator/README.md +++ /dev/null @@ -1,82 +0,0 @@ -# EmailValidator -[![Build Status](https://travis-ci.org/egulias/EmailValidator.svg?branch=master)](https://travis-ci.org/egulias/EmailValidator) [![Coverage Status](https://coveralls.io/repos/egulias/EmailValidator/badge.svg?branch=master)](https://coveralls.io/r/egulias/EmailValidator?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6/small.png)](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6) -============================= -## Suported RFCs ## -This library aims to support: - -RFC 5321, 5322, 6530, 6531, 6532. - -## Requirements ## - - * [Composer](https://getcomposer.org) is required for installation - * [Spoofchecking](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/SpoofCheckValidation.php) and [DNSCheckValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/DNSCheckValidation.php) validation requires that your PHP system has the [PHP Internationalization Libraries](https://php.net/manual/en/book.intl.php) (also known as PHP Intl) - -## Installation ## - -Run the command below to install via Composer - -```shell -composer require egulias/email-validator -``` - -## Getting Started ## -`EmailValidator`requires you to decide which (or combination of them) validation/s strategy/ies you'd like to follow for each [validation](#available-validations). - -A basic example with the RFC validation -```php -<?php - -use Egulias\EmailValidator\EmailValidator; -use Egulias\EmailValidator\Validation\RFCValidation; - -$validator = new EmailValidator(); -$validator->isValid("example@example.com", new RFCValidation()); //true -``` - - -### Available validations ### - -1. [RFCValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/RFCValidation.php) -2. [NoRFCWarningsValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/NoRFCWarningsValidation.php) -3. [DNSCheckValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/DNSCheckValidation.php) -4. [SpoofCheckValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/SpoofCheckValidation.php) -5. [MultipleValidationWithAnd](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/MultipleValidationWithAnd.php) -6. [Your own validation](#how-to-extend) - -`MultipleValidationWithAnd` - -It is a validation that operates over other validations performing a logical and (&&) over the result of each validation. - -```php -<?php - -use Egulias\EmailValidator\EmailValidator; -use Egulias\EmailValidator\Validation\DNSCheckValidation; -use Egulias\EmailValidator\Validation\MultipleValidationWithAnd; -use Egulias\EmailValidator\Validation\RFCValidation; - -$validator = new EmailValidator(); -$multipleValidations = new MultipleValidationWithAnd([ - new RFCValidation(), - new DNSCheckValidation() -]); -$validator->isValid("example@example.com", $multipleValidations); //true -``` - -### How to extend ### - -It's easy! You just need to implement [EmailValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/EmailValidation.php) and you can use your own validation. - - -## Other Contributors ## -(You can find current contributors [here](https://github.com/egulias/EmailValidator/graphs/contributors)) - -As this is a port from another library and work, here are other people related to the previous one: - -* Ricard Clau [@ricardclau](https://github.com/ricardclau): Performance against PHP built-in filter_var -* Josepf Bielawski [@stloyd](https://github.com/stloyd): For its first re-work of Dominic's lib -* Dominic Sayers [@dominicsayers](https://github.com/dominicsayers): The original isemail function - -## License ## -Released under the MIT License attached with this code. - diff --git a/egulias/email-validator/composer.json b/egulias/email-validator/composer.json index 4956da9e..a275696a 100644 --- a/egulias/email-validator/composer.json +++ b/egulias/email-validator/composer.json @@ -2,7 +2,6 @@ "name": "egulias/email-validator", "description": "A library for validating emails against several RFCs", "homepage": "https://github.com/egulias/EmailValidator", - "type": "Library", "keywords": ["email", "validation", "validator", "emailvalidation", "emailvalidator"], "license": "MIT", "authors": [ @@ -13,33 +12,27 @@ "dev-master": "2.1.x-dev" } }, - "repositories": [ - { - "type": "git", - "url": "https://github.com/dominicsayers/isemail" - } - ], - "require": { - "php": ">= 5.5", - "doctrine/lexer": "^1.0.1" + "require": { + "php": ">=5.5", + "doctrine/lexer": "^1.0.1", + "symfony/polyfill-intl-idn": "^1.10" }, - "require-dev" : { - "satooshi/php-coveralls": "^1.0.1", - "phpunit/phpunit": "^4.8.35||^5.7||^6.0", - "symfony/phpunit-bridge": "^4.4@dev", - "dominicsayers/isemail": "dev-master" + "require-dev": { + "dominicsayers/isemail": "^3.0.7", + "phpunit/phpunit": "^4.8.36|^7.5.15", + "satooshi/php-coveralls": "^1.0.1" }, "suggest": { "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" }, "autoload": { "psr-4": { - "Egulias\\EmailValidator\\": "EmailValidator" + "Egulias\\EmailValidator\\": "src" } }, "autoload-dev": { "psr-4": { - "Egulias\\Tests\\": "test" + "Egulias\\EmailValidator\\Tests\\": "tests" } } } diff --git a/egulias/email-validator/phpunit.xml.dist b/egulias/email-validator/phpunit.xml.dist deleted file mode 100644 index 754445a7..00000000 --- a/egulias/email-validator/phpunit.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<phpunit backupGlobals="false" - backupStaticAttributes="false" - colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" - stopOnFailure="false" - bootstrap="vendor/autoload.php" -> -<testsuites> - <testsuite name="EmailValidator Test Suite"> - <directory>./Tests/EmailValidator</directory> - <exclude>./vendor/</exclude> - </testsuite> -</testsuites> - -<filter> - <whitelist> - <directory>./EmailValidator/</directory> - </whitelist> -</filter> - -<listeners> - <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" /> -</listeners> -</phpunit> |