mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-31 20:50:01 +00:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f61c17d6fe | |||
| 55180567a5 | |||
| 1f474a4409 | |||
| 44bde38176 | |||
| 99b4f8e448 | |||
| b116835bd8 | |||
| 54ed41932f | |||
| 1f86cf9d26 | |||
| c00947c244 | |||
| b78e88adce | |||
| ab7fa5157f | |||
| afd9a6a92c | |||
| 5d82c6c6a2 | |||
| 0cb5e361d5 | |||
| cfe6310bd8 | |||
| 777cffae66 | |||
| 9c360e0ef7 | |||
| 558244a113 | |||
| 1bb1fe652b | |||
| 56f82815d2 | |||
| 4000d347c6 | |||
| 5462ecbd75 |
@@ -1,3 +1,4 @@
|
||||
report/
|
||||
vendor/
|
||||
.idea
|
||||
.local.php.vimrc
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ php:
|
||||
before_script:
|
||||
- wget http://getcomposer.org/composer.phar
|
||||
- php composer.phar install
|
||||
script: phpunit -c tests/ tests/
|
||||
script: phpunit
|
||||
|
||||
@@ -42,9 +42,9 @@ if ($result) {
|
||||
##Contributors##
|
||||
As this is a port from another library and work, here are other people related to the previous:
|
||||
|
||||
*Ricard Clau @ricardclau : Performance against PHP built-in filter_var
|
||||
*Josepf Bielawski @stloyd: For its first re-work of Dominic's lib
|
||||
*Domini Sayers @dominicsayers: The original isemail function
|
||||
* Ricard Clau [@ricardclau](http://github.com/ricardclau): Performance against PHP built-in filter_var
|
||||
* Josepf Bielawski [@stloyd](http://github.com/stloyd): For its first re-work of Dominic's lib
|
||||
* Dominic Sayers [@dominicsayers](http://github.com/dominicsayers): The original isemail function
|
||||
|
||||
##Licence##
|
||||
Released under the MIT Licence attached with this code.
|
||||
|
||||
+7
-2
@@ -8,13 +8,18 @@
|
||||
"authors": [
|
||||
{"name": "Eduardo Gulias Davis"}
|
||||
],
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">= 5.3.3",
|
||||
"jms/parser-lib": "dev-master"
|
||||
"doctrine/lexer": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"egulias\\": "src/"
|
||||
"Egulias\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+157
-63
@@ -1,99 +1,193 @@
|
||||
{
|
||||
"hash": "6aabe7b13fcf2af4eeb25983a1c6de35",
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "ec97acf9cb298074065a27ad27d42b64",
|
||||
"packages": [
|
||||
{
|
||||
"name": "jms/parser-lib",
|
||||
"version": "dev-master",
|
||||
"name": "doctrine/lexer",
|
||||
"version": "v1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/schmittjoh/parser-lib",
|
||||
"reference": "4d469a70c6dd03f921cbdeadafbcb261bb23e8b0"
|
||||
"url": "https://github.com/doctrine/lexer.git",
|
||||
"reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/schmittjoh/parser-lib/archive/4d469a70c6dd03f921cbdeadafbcb261bb23e8b0.zip",
|
||||
"reference": "4d469a70c6dd03f921cbdeadafbcb261bb23e8b0",
|
||||
"url": "https://api.github.com/repos/doctrine/lexer/zipball/2f708a85bb3aab5d99dab8be435abd73e0b18acb",
|
||||
"reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"phpoption/phpoption": ">=0.9,<2.0-dev"
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"time": "2012-11-30 08:11:04",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"JMS\\": "src/"
|
||||
"Doctrine\\Common\\Lexer\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache2"
|
||||
],
|
||||
"description": "A library for easily creating recursive-descent parsers."
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/schmittjoh/php-option",
|
||||
"reference": "1.0.0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://github.com/schmittjoh/php-option/archive/1.0.0.zip",
|
||||
"reference": "1.0.0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2012-11-18 14:14:12",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"PhpOption\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache2"
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Johannes M. Schmitt",
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com",
|
||||
"homepage": "http://www.instaclick.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com",
|
||||
"homepage": "http://jmsyst.com",
|
||||
"role": "Developer of wrapped JMSSerializerBundle"
|
||||
}
|
||||
],
|
||||
"description": "Option Type for PHP",
|
||||
"description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"php",
|
||||
"language",
|
||||
"type",
|
||||
"option"
|
||||
]
|
||||
"lexer",
|
||||
"parser"
|
||||
],
|
||||
"time": "2013-01-12 18:59:04"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v2.3.4",
|
||||
"target-dir": "Symfony/Component/Translation",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Translation.git",
|
||||
"reference": "65f888291f0896ad492f9abc6dc05c998373aded"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Translation/zipball/65f888291f0896ad492f9abc6dc05c998373aded",
|
||||
"reference": "65f888291f0896ad492f9abc6dc05c998373aded",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/config": "~2.0",
|
||||
"symfony/yaml": "~2.2"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/config": "",
|
||||
"symfony/yaml": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Translation\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Translation Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-08-26 05:49:51"
|
||||
},
|
||||
{
|
||||
"name": "symfony/validator",
|
||||
"version": "dev-master",
|
||||
"target-dir": "Symfony/Component/Validator",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Validator.git",
|
||||
"reference": "d98ac2aac2cccb7032b08cd79eeb579ed35c9a66"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Validator/zipball/d98ac2aac2cccb7032b08cd79eeb579ed35c9a66",
|
||||
"reference": "d98ac2aac2cccb7032b08cd79eeb579ed35c9a66",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"symfony/translation": "~2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/config": "~2.2",
|
||||
"symfony/http-foundation": "~2.1",
|
||||
"symfony/intl": "~2.3",
|
||||
"symfony/yaml": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"doctrine/common": "",
|
||||
"symfony/config": "",
|
||||
"symfony/http-foundation": "",
|
||||
"symfony/intl": "",
|
||||
"symfony/yaml": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Validator\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Validator Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-08-19 20:44:22"
|
||||
}
|
||||
],
|
||||
"packages-dev": null,
|
||||
"packages-dev": [
|
||||
|
||||
],
|
||||
"aliases": [
|
||||
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"jms/parser-lib": 20
|
||||
}
|
||||
"symfony/validator": 20
|
||||
},
|
||||
"platform": {
|
||||
"php": ">= 5.3.3"
|
||||
},
|
||||
"platform-dev": [
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,11 +9,18 @@
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="bootstrap.php"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="EmailValidator Test Suite">
|
||||
<directory>./IsEmail/</directory>
|
||||
<directory>./tests/egulias/Tests/</directory>
|
||||
<exclude>./vendor/</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<blacklist>
|
||||
<directory>./vendor</directory>
|
||||
</blacklist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
+41
-65
@@ -1,15 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace egulias\EmailValidator;
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
use JMS\Parser\AbstractLexer;
|
||||
use Doctrine\Common\Lexer\AbstractLexer;
|
||||
|
||||
class EmailLexer extends AbstractLexer
|
||||
{
|
||||
//ASCII values
|
||||
const C_DEL = 127;
|
||||
const C_NUL = 0;
|
||||
|
||||
const C_DEL = 127;
|
||||
const C_NUL = 0;
|
||||
const S_AT = 64;//'@';
|
||||
const S_BACKSLASH = 92;//'\\';
|
||||
const S_DOT = 46;//'.';
|
||||
@@ -74,28 +73,21 @@ class EmailLexer extends AbstractLexer
|
||||
protected $previous;
|
||||
|
||||
/**
|
||||
* getName
|
||||
* find
|
||||
*
|
||||
* @param string $type
|
||||
* @param mixed $type
|
||||
*
|
||||
* @return string $name
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
public function getName($type)
|
||||
{
|
||||
$ref = new \ReflectionClass($this);
|
||||
foreach ($ref->getConstants() as $name => $value) {
|
||||
if ($value === $type) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('There is no token with value %s.', json_encode($type)));
|
||||
}
|
||||
|
||||
public function find($type)
|
||||
{
|
||||
$search = clone $this;
|
||||
$search->skipUntil($type);
|
||||
|
||||
if (!$search->lookahead) {
|
||||
throw new \UnexpectedValueException($type . ' not found');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,67 +112,51 @@ class EmailLexer extends AbstractLexer
|
||||
return parent::moveNext();
|
||||
}
|
||||
|
||||
public function isNext($type)
|
||||
/**
|
||||
* Lexical catchable patterns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCatchablePatterns()
|
||||
{
|
||||
return null !== $this->next && $type === $this->next[0];
|
||||
}
|
||||
|
||||
public function isNextAny(array $types)
|
||||
{
|
||||
foreach ($types as $i => $type) {
|
||||
$types[$i] = array_search($type, $this->charValue);
|
||||
}
|
||||
|
||||
return parent::isNextAny($types);
|
||||
return array(
|
||||
'[a-zA-Z_]+[4,6]?',
|
||||
'[0-9]+',
|
||||
'\r\n',
|
||||
'::',
|
||||
'\s+',
|
||||
'[\x1-\x1F]+',
|
||||
'.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inherit}
|
||||
* Lexical non-catchable patterns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRegex()
|
||||
protected function getNonCatchablePatterns()
|
||||
{
|
||||
return '/
|
||||
# Alphabetic-chars and IPv6 or 4
|
||||
([a-zA-Z]+[4,6]?)
|
||||
|
||||
# Numbers
|
||||
| ([0-9]+)
|
||||
|
||||
#CRLF
|
||||
| (\r\n)
|
||||
|
||||
#double colon
|
||||
| (::)
|
||||
|
||||
# Whitespace
|
||||
| (\s+)
|
||||
|
||||
#Special
|
||||
| ([\x1-\x1F]+)
|
||||
|
||||
# Anything that is left as single character tokens
|
||||
| (.)
|
||||
/xu';
|
||||
return array('[\x7f-\xff]+');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inherit}
|
||||
* Retrieve token type. Also processes the token value if necessary.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws \InvalidArgumentException
|
||||
* @return integer
|
||||
*/
|
||||
protected function determineTypeAndValue($value)
|
||||
protected function getType(&$value)
|
||||
{
|
||||
if (isset($this->charValue[$value])) {
|
||||
return array($value, $this->charValue[$value]);
|
||||
return $this->charValue[$value];
|
||||
}
|
||||
|
||||
if (preg_match('/[\x1-\x1F]+/', $value)) {
|
||||
return array($value, self::INVALID);
|
||||
return self::INVALID;
|
||||
}
|
||||
|
||||
if (preg_match('/[\x7f-\xff]+/', $value)) {
|
||||
throw new \InvalidArgumentException(sprintf('There is no token with value %s.', json_encode($value)));
|
||||
}
|
||||
|
||||
return array($value, self::GENERIC);
|
||||
|
||||
return self::GENERIC;
|
||||
}
|
||||
}
|
||||
+107
-112
@@ -1,63 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace egulias\EmailValidator;
|
||||
|
||||
use JMS\Parser\AbstractParser;
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
/**
|
||||
* EmailParser
|
||||
*
|
||||
* @author Eduardo Gulias Davis <me@egulias.com>
|
||||
*/
|
||||
class EmailParser extends AbstractParser
|
||||
class EmailParser
|
||||
{
|
||||
|
||||
protected $warnings = array();
|
||||
protected $localPart = '';
|
||||
protected $domainPart = '';
|
||||
protected $index = 0;
|
||||
|
||||
public function __construct(EmailLexer $lexer)
|
||||
{
|
||||
$this->lexer = $lexer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inherit}
|
||||
* parse
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parseInternal()
|
||||
public function parse($str)
|
||||
{
|
||||
$this->lexer->setInput($str);
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->token[0] === EmailLexer::S_AT) {
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
||||
throw new \InvalidArgumentException('ERR_NOLOCALPART');
|
||||
}
|
||||
$this->parseLocalPart();
|
||||
$this->parseDomainPart();
|
||||
$parts = explode('@', $str);
|
||||
|
||||
if (strlen($this->localPart . '@' . $this->domainPart) > 254) {
|
||||
if (strlen($parts[0] . '@' . $this->domainPart) > 254) {
|
||||
// http://tools.ietf.org/html/rfc5321#section-4.1.2
|
||||
// Forward-path = Path
|
||||
//
|
||||
// Path = "<" [ A-d-l ":" ] Mailbox ">"
|
||||
//
|
||||
// http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3
|
||||
// The maximum total length of a reverse-path or forward-path is 256
|
||||
// octets (including the punctuation and element separators).
|
||||
//
|
||||
// Thus, even without (obsolete) routing information, the Mailbox can
|
||||
// only be 254 characters long. This is confirmed by this verified
|
||||
// erratum to RFC 3696:
|
||||
//
|
||||
// http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690
|
||||
// However, there is a restriction in RFC 2821 on the length of an
|
||||
// address in MAIL and RCPT commands of 254 characters. Since addresses
|
||||
// that do not fit in those fields are not normally useful, the upper
|
||||
// limit on address lengths should normally be considered to be 254.
|
||||
//
|
||||
// http://tools.ietf.org/html/rfc1035#section-2.3.4
|
||||
$this->warnings[] = EmailValidator::RFC5322_TOOLONG;
|
||||
}
|
||||
|
||||
return array('local' => $this->localPart, 'domain' => $this->domainPart);
|
||||
return array('local' => $parts[0], 'domain' => $this->domainPart);
|
||||
}
|
||||
|
||||
/**
|
||||
* getWarnings
|
||||
* getWarnings
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -79,40 +74,45 @@ class EmailParser extends AbstractParser
|
||||
{
|
||||
$domain = '';
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->token[0] === EmailLexer::S_AT) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
||||
throw new \InvalidArgumentException('ERR_CONSECUTIVEATS');
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_DOT) {
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT) {
|
||||
throw new \InvalidArgumentException('ERR_DOT_START');
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_EMPTY) {
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_EMPTY) {
|
||||
throw new \InvalidArgumentException('ERR_NODOMAIN');
|
||||
}
|
||||
// Comments at the start of the domain are deprecated in the text
|
||||
// Comments at the start of a subdomain are obs-domain
|
||||
// (http://tools.ietf.org/html/rfc5322#section-3.4.1)
|
||||
if ($this->lexer->token[0] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->warnings[] = EmailValidator::DEPREC_COMMENT;
|
||||
$this->parseComments();
|
||||
}
|
||||
|
||||
do {
|
||||
$prev = $this->lexer->getPrevious();
|
||||
if ($this->lexer->token[0] === EmailLexer::S_OPENQBRACKET && $prev[0] !== EmailLexer::S_AT) {
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
||||
throw new \InvalidArgumentException('ERR_CONSECUTIVEATS');
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
//$this->warnings[] = EmailValidator::CFWS_COMMENT;
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->parseComments();
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_DOT && $this->lexer->isNext(EmailLexer::S_DOT)) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
throw new \InvalidArgumentException('ERR_CONSECUTIVEDOTS');
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_HYPHEN && $this->lexer->isNext(EmailLexer::S_DOT)) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
throw new \InvalidArgumentException('ERR_DOMAINHYPHENEND');
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_OPENQBRACKET) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET) {
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_CLOSEQBRACKET);
|
||||
} catch (\RuntimeException $e) {
|
||||
@@ -121,7 +121,7 @@ class EmailParser extends AbstractParser
|
||||
$this->parseDomainLiteral();
|
||||
}
|
||||
|
||||
if ($this->lexer->token[0] === EmailLexer::S_OPENBRACKET) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENBRACKET) {
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_CLOSEBRACKET);
|
||||
} catch (\RuntimeException $e) {
|
||||
@@ -130,44 +130,43 @@ class EmailParser extends AbstractParser
|
||||
$this->parseDomainLiteral();
|
||||
}
|
||||
|
||||
if ($this->lexer->token[0] === EmailLexer::S_BACKSLASH && $this->lexer->isNext(EmailLexer::GENERIC)) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
|
||||
&& $this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
}
|
||||
|
||||
if (
|
||||
$this->lexer->token[0] === EmailLexer::S_DOT &&
|
||||
$prev[0] === EmailLexer::GENERIC &&
|
||||
strlen($prev[2]) > 63
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
|
||||
$prev['type'] === EmailLexer::GENERIC &&
|
||||
strlen($prev['value']) > 63
|
||||
) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_LABEL_TOOLONG;
|
||||
}
|
||||
|
||||
if (
|
||||
$this->lexer->token[0] === EmailLexer::S_SP ||
|
||||
$this->lexer->token[0] === EmailLexer::S_HTAB ||
|
||||
$this->lexer->token[0] === EmailLexer::S_CR ||
|
||||
$this->lexer->token[0] === EmailLexer::S_LF ||
|
||||
$this->lexer->token[0] === EmailLexer::CRLF
|
||||
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
|
||||
) {
|
||||
$this->parseFWS();
|
||||
}
|
||||
$domain .= $this->lexer->token[2];
|
||||
$domain .= $this->lexer->token['value'];
|
||||
$this->lexer->moveNext();
|
||||
} while ($this->lexer->token);
|
||||
|
||||
$last = $this->lexer->getPrevious();
|
||||
$length = strlen($last[2]);
|
||||
$prev = $this->lexer->getPrevious();
|
||||
$length = strlen($prev['value']);
|
||||
|
||||
if ($last[0] === EmailLexer::S_DOT) {
|
||||
if ($prev['type'] === EmailLexer::S_DOT) {
|
||||
throw new \InvalidArgumentException('ERR_DOT_END');
|
||||
}
|
||||
if ($last[0] === EmailLexer::S_HYPHEN) {
|
||||
if ($prev['type'] === EmailLexer::S_HYPHEN) {
|
||||
throw new \InvalidArgumentException('ERR_DOMAINHYPHENEND');
|
||||
}
|
||||
if ($length > 254) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_DOMAIN_TOOLONG;
|
||||
}
|
||||
if ($last[0] === EmailLexer::S_CR) {
|
||||
if ($prev['type'] === EmailLexer::S_CR) {
|
||||
throw new \InvalidArgumentException('ERR_FWS_CRLF_END');
|
||||
}
|
||||
$this->domainPart = $domain;
|
||||
@@ -177,15 +176,15 @@ class EmailParser extends AbstractParser
|
||||
{
|
||||
$IPv6TAG = false;
|
||||
$addressLiteral = '';
|
||||
if ($this->lexer->isNext(EmailLexer::S_COLON)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_COLON)) {
|
||||
// Address starts with a single colon
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_COLONSTRT;
|
||||
}
|
||||
if ($this->lexer->isNext(EmailLexer::S_IPV6TAG)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) {
|
||||
try {
|
||||
$lexer = clone $this->lexer;
|
||||
$lexer->moveNext();
|
||||
if ($lexer->isNext(EmailLexer::S_DOUBLECOLON)) {
|
||||
if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_COLONSTRT;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -193,50 +192,48 @@ class EmailParser extends AbstractParser
|
||||
|
||||
}
|
||||
do {
|
||||
if ($this->lexer->token[0] === EmailLexer::C_NUL) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::C_NUL) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_DTEXT');
|
||||
} elseif (
|
||||
$this->lexer->token[0] === EmailLexer::INVALID ||
|
||||
$this->lexer->token[0] === EmailLexer::C_DEL ||
|
||||
$this->lexer->token[0] === EmailLexer::S_LF
|
||||
} elseif ($this->lexer->token['type'] === EmailLexer::INVALID ||
|
||||
$this->lexer->token['type'] === EmailLexer::C_DEL ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_LF
|
||||
) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_DOMLIT_OBSDTEXT;
|
||||
}
|
||||
if ($this->lexer->isNextAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) {
|
||||
if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_DTEXT');
|
||||
}
|
||||
if ($this->lexer->isNextAny(array(EmailLexer::S_HTAB, EmailLexer::S_SP))) {
|
||||
if ($this->lexer->isNextTokenAny(array(EmailLexer::S_HTAB, EmailLexer::S_SP))) {
|
||||
$this->warnings[] = EmailValidator::CFWS_FWS;
|
||||
$this->parseFWS();
|
||||
}
|
||||
if ($this->lexer->isNext(EmailLexer::S_CR)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_CR)) {
|
||||
throw new \InvalidArgumentException("ERR_CR_NO_LF");
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_BACKSLASH) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_DOMLIT_OBSDTEXT;
|
||||
$addressLiteral .= $this->lexer->token[2];
|
||||
$addressLiteral .= $this->lexer->token['value'];
|
||||
$this->lexer->moveNext();
|
||||
$this->validateQuotedPair();
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_CLOSEQBRACKET) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEQBRACKET) {
|
||||
break;
|
||||
}
|
||||
if (
|
||||
$this->lexer->token[0] === EmailLexer::S_SP ||
|
||||
$this->lexer->token[0] === EmailLexer::S_HTAB ||
|
||||
$this->lexer->token[0] === EmailLexer::CRLF
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_SP ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_HTAB ||
|
||||
$this->lexer->token['type'] === EmailLexer::CRLF
|
||||
) {
|
||||
$this->parseFWS();
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_IPV6TAG) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) {
|
||||
$IPv6TAG = true;
|
||||
}
|
||||
$addressLiteral .= $this->lexer->token[2];
|
||||
$addressLiteral .= $this->lexer->token['value'];
|
||||
|
||||
} while ($this->lexer->moveNext());
|
||||
// Revision 2.7: Daniel Marschall's new IPv6 testing strategy
|
||||
$prev = $this->lexer->getPrevious();
|
||||
if ($prev[0] === EmailLexer::S_COLON) {
|
||||
if ($prev['type'] === EmailLexer::S_COLON) {
|
||||
// Address ends with a single colon
|
||||
$this->warnings[] = EmailValidator::RFC5322_IPV6_COLONEND;
|
||||
}
|
||||
@@ -315,7 +312,8 @@ class EmailParser extends AbstractParser
|
||||
*/
|
||||
private function validateQuotedPair()
|
||||
{
|
||||
if (!($this->lexer->token[0] === EmailLexer::INVALID || $this->lexer->token[0] === EmailLexer::C_DEL)) {
|
||||
if (!($this->lexer->token['type'] === EmailLexer::INVALID
|
||||
|| $this->lexer->token['type'] === EmailLexer::C_DEL)) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_QPAIR');
|
||||
}
|
||||
// SP & HTAB are allowed
|
||||
@@ -325,14 +323,16 @@ class EmailParser extends AbstractParser
|
||||
private function parseLocalPart()
|
||||
{
|
||||
$closingQuote = false;
|
||||
while ($this->lexer->token[0] !== EmailLexer::S_AT) {
|
||||
while ($this->lexer->token['type'] !== EmailLexer::S_AT && $this->lexer->token) {
|
||||
|
||||
$previous = $this->lexer->getPrevious();
|
||||
if ($this->lexer->token[0] === EmailLexer::S_DOT && !$this->lexer->getPrevious()) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && !$this->lexer->getPrevious()) {
|
||||
throw new \InvalidArgumentException('ERR_DOT_START');
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_DQUOTE) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DQUOTE) {
|
||||
//@TODO this can be improbed
|
||||
if (!$closingQuote) {
|
||||
if ($this->lexer->isNext(EmailLexer::GENERIC) && $previous[0] === EmailLexer::GENERIC) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
}
|
||||
$this->warnings[] = EmailValidator::RFC5321_QUOTEDSTRING;
|
||||
@@ -343,34 +343,31 @@ class EmailParser extends AbstractParser
|
||||
throw new \InvalidArgumentException('ERR_UNCLOSEDQUOTEDSTR');
|
||||
}
|
||||
}
|
||||
//if ($previous[0] != EmailLexer::S_BACKSLASH) {
|
||||
// throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
//}
|
||||
//$this->warnings[] = EmailValidator::DEPREC_LOCALPART;
|
||||
}
|
||||
//Comments
|
||||
if ($this->lexer->token[0] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->parseComments();
|
||||
}
|
||||
|
||||
if ($this->lexer->token[0] === EmailLexer::S_DOT && $this->lexer->isNext(EmailLexer::S_DOT)) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
|
||||
$this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
throw new \InvalidArgumentException('ERR_CONSECUTIVEDOTS');
|
||||
}
|
||||
|
||||
if ($this->lexer->token[0] === EmailLexer::S_DOT && $this->lexer->isNext(EmailLexer::S_AT)) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_AT)) {
|
||||
throw new \InvalidArgumentException('ERR_DOT_END');
|
||||
}
|
||||
|
||||
if ($this->lexer->token[0] === EmailLexer::S_BACKSLASH) {
|
||||
//if ($this->lexer->isNextAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) {
|
||||
//if ($this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
||||
// $this->warnings[] = EmailValidator::DEPREC_QP;
|
||||
//}
|
||||
if ($this->lexer->isNext(EmailLexer::GENERIC)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextAny(
|
||||
if ($this->lexer->isNextTokenAny(
|
||||
array(
|
||||
EmailLexer::INVALID, EmailLexer::S_LOWERTHAN, EmailLexer::S_GREATERTHAN
|
||||
)
|
||||
@@ -379,12 +376,11 @@ class EmailParser extends AbstractParser
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
}
|
||||
|
||||
if (
|
||||
$this->lexer->token[0] === EmailLexer::S_SP ||
|
||||
$this->lexer->token[0] === EmailLexer::S_HTAB ||
|
||||
$this->lexer->token[0] === EmailLexer::S_CR ||
|
||||
$this->lexer->token[0] === EmailLexer::S_LF ||
|
||||
$this->lexer->token[0] === EmailLexer::CRLF
|
||||
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
|
||||
) {
|
||||
$this->parseFWS();
|
||||
}
|
||||
@@ -393,7 +389,7 @@ class EmailParser extends AbstractParser
|
||||
}
|
||||
|
||||
$prev = $this->lexer->getPrevious();
|
||||
if ($prev[1] > EmailValidator::RFC5322_LOCAL_TOOLONG) {
|
||||
if (strlen($prev['value']) > EmailValidator::RFC5322_LOCAL_TOOLONG) {
|
||||
$this->warnings[] = EmailValidator::RFC5322_LOCAL_TOOLONG;
|
||||
}
|
||||
}
|
||||
@@ -406,28 +402,28 @@ class EmailParser extends AbstractParser
|
||||
private function parseComments()
|
||||
{
|
||||
$this->warnings[] = EmailValidator::CFWS_COMMENT;
|
||||
while (!$this->lexer->isNext(EmailLexer::S_CLOSEPARENTHESIS)) {
|
||||
while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS);
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new \InvalidArgumentException('ERR_UNCLOSEDCOMMENT');
|
||||
}
|
||||
//$this->lexer->moveNext();
|
||||
|
||||
//scaping in a comment
|
||||
if ($this->lexer->token[0] === EmailLexer::S_BACKSLASH) {
|
||||
if ($this->lexer->isNextAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) {
|
||||
if ($this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
||||
$this->warnings[] = EmailValidator::DEPREC_QP;
|
||||
}
|
||||
}
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->isNext(EmailLexer::GENERIC)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) || EmailLexer::S_EMPTY === $this->lexer->peek()) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||
}
|
||||
|
||||
if ($this->lexer->isNext(EmailLexer::S_AT)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_AT)) {
|
||||
$this->warnings[] = EmailValidator::DEPREC_CFWS_NEAR_AT;
|
||||
}
|
||||
}
|
||||
@@ -441,25 +437,24 @@ class EmailParser extends AbstractParser
|
||||
{
|
||||
$previous = $this->lexer->getPrevious();
|
||||
|
||||
if ($this->lexer->token[0] === EmailLexer::CRLF && $this->lexer->isNext(EmailLexer::CRLF)) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::CRLF && $this->lexer->isNextToken(EmailLexer::CRLF)) {
|
||||
throw new \InvalidArgumentException("ERR_FWS_CRLF_X2");
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_CR) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CR) {
|
||||
throw new \InvalidArgumentException("ERR_CR_NO_LF");
|
||||
}
|
||||
if (
|
||||
!$this->lexer->isNextAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB)) &&
|
||||
$this->lexer->token[0] === EmailLexer::CRLF ) {
|
||||
throw new \InvalidArgumentException("ERR_FWS_CRLF_END");
|
||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB)) &&
|
||||
$this->lexer->token['type'] === EmailLexer::CRLF ) {
|
||||
throw new \InvalidArgumentException("ERR_FWS_CRLF_END");
|
||||
}
|
||||
if ($this->lexer->isNext(EmailLexer::GENERIC) && $this->lexer->token[0] !== EmailLexer::S_SP) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $this->lexer->token['type'] !== EmailLexer::S_SP) {
|
||||
throw new \InvalidArgumentException("ERR_ATEXT_AFTER_CFWS");
|
||||
}
|
||||
if ($this->lexer->token[0] === EmailLexer::S_LF || $this->lexer->token[0] === EmailLexer::C_NUL) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) {
|
||||
throw new \InvalidArgumentException('ERR_EXPECTING_CTEXT');
|
||||
}
|
||||
|
||||
if ($this->lexer->isNext(EmailLexer::S_AT) || $previous[0] === EmailLexer::S_AT) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) {
|
||||
$this->warnings[] = EmailValidator::DEPREC_CFWS_NEAR_AT;
|
||||
} else {
|
||||
$this->warnings[] = EmailValidator::CFWS_FWS;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace egulias\EmailValidator;
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
/**
|
||||
* EmailValidator
|
||||
@@ -1,320 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace tests;
|
||||
|
||||
require_once 'EmailValidator.php';
|
||||
|
||||
|
||||
class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $validator;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->validator = new \EmailValidator\EmailValidator();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->validator = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidEmails
|
||||
*/
|
||||
public function testValidEmails($email)
|
||||
{
|
||||
$this->assertTrue($this->validator->isValid($email));
|
||||
}
|
||||
|
||||
public function getValidEmails()
|
||||
{
|
||||
return array(
|
||||
array('fabien@symfony.com'),
|
||||
array('example@example.co.uk'),
|
||||
array('fabien_potencier@example.fr'),
|
||||
array('example@localhost'),
|
||||
array('example((example))@fakedfake.co.uk'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getExistingEmails
|
||||
*/
|
||||
public function testValidExistingEmails($email)
|
||||
{
|
||||
$this->assertTrue($this->validator->isValid($email, true));
|
||||
}
|
||||
|
||||
public function getExistingEmails()
|
||||
{
|
||||
return array(
|
||||
array('fabien@symfony.com'),
|
||||
array('stloyd@o2.pl'),
|
||||
array('ominic@sayers.cc'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNonexistingEmails
|
||||
*/
|
||||
public function testValidNonexistingEmails($email)
|
||||
{
|
||||
$this->assertTrue($this->validator->isValid($email, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNonexistingEmails
|
||||
*/
|
||||
public function testValidNonexistingEmailsWithStrict($email)
|
||||
{
|
||||
$this->assertFalse($this->validator->isValid($email, true, true));
|
||||
}
|
||||
|
||||
public function getNonexistingEmails()
|
||||
{
|
||||
return array(
|
||||
array('example@fakedfake.co.uk'),
|
||||
array('fabien_potencier@non-existing.fr'),
|
||||
array('example@localhost'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidEmails
|
||||
*/
|
||||
public function testTInvalidEmails($email)
|
||||
{
|
||||
$this->assertFalse($this->validator->isValid($email));
|
||||
}
|
||||
|
||||
public function getInvalidEmails()
|
||||
{
|
||||
return array(
|
||||
array('example.@example.co.uk'),
|
||||
array('(fabien_potencier@example.fr)'),
|
||||
array('example(example)example@example.co.uk'),
|
||||
array('.example@localhost'),
|
||||
array('ex\ample@localhost'),
|
||||
array('example@local\host'),
|
||||
array('example@localhost.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidEmailsWithErrors
|
||||
*/
|
||||
public function testInvalidEmailsWithErrorsCheck($errors, $email)
|
||||
{
|
||||
$this->assertFalse($this->validator->isValid($email));
|
||||
|
||||
$this->assertEquals($errors, $this->validator->getErrors());
|
||||
}
|
||||
|
||||
public function getInvalidEmailsWithErrors()
|
||||
{
|
||||
return array(
|
||||
array(array(\EmailValidator\EmailValidator::ERR_NOLOCALPART), '@example.co.uk'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_NODOMAIN), 'example@'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_DOMAINHYPHENEND), 'example@example-.co.uk'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_DOMAINHYPHENEND), 'example@example-'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_CONSECUTIVEATS), 'example@@example.co.uk'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_CONSECUTIVEDOTS), 'example..example@example.co.uk'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_CONSECUTIVEDOTS), 'example@example..co.uk'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_EXPECTING_ATEXT), '<fabien_potencier>@example.fr'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_DOT_START), '.example@localhost'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_DOT_START), 'example@.localhost'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_DOT_END), 'example@localhost.'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_DOT_END), 'example.@example.co.uk'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_UNCLOSEDCOMMENT), '(example@localhost'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_UNCLOSEDQUOTEDSTR), '"example@localhost'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_EXPECTING_ATEXT), 'exa"mple@localhost'),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_EXPECTING_ATEXT), "exampl\ne@example.co.uk"),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_EXPECTING_DTEXT), "example@[[]"),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_ATEXT_AFTER_CFWS), "exampl\te@example.co.uk"),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_CR_NO_LF), "example@exa\rmple.co.uk"),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_CR_NO_LF), "example@[\r]"),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_CR_NO_LF), "exam\rple@example.co.uk"),
|
||||
array(array(\EmailValidator\EmailValidator::ERR_CR_NO_LF), "\"\r\"@localhost"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidEmailsWithWarnings
|
||||
*/
|
||||
public function testInvalidEmailsWithWarningsCheck($warnings, $email)
|
||||
{
|
||||
$this->assertTrue($this->validator->isValid($email, true));
|
||||
|
||||
$this->assertEquals($warnings, $this->validator->getWarnings());
|
||||
}
|
||||
|
||||
public function getInvalidEmailsWithWarnings()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
),
|
||||
'example @example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
),
|
||||
'example@ example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::CFWS_COMMENT,
|
||||
),
|
||||
'example@example(example).co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::CFWS_COMMENT,
|
||||
\EmailValidator\EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
),
|
||||
'example(example)@example.co.uk'
|
||||
),
|
||||
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5321_QUOTEDSTRING,
|
||||
\EmailValidator\EmailValidator::CFWS_FWS,
|
||||
),
|
||||
"\"\t\"@example.co.uk"
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[127.0.0.1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5321_IPV6DEPRECATED,
|
||||
\EmailValidator\EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370::]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_IPV6_MAXGRPS,
|
||||
\EmailValidator\EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334::]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_IPV6_2X2XCOLON,
|
||||
\EmailValidator\EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:1::1::1]'
|
||||
),
|
||||
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_DOMLIT_OBSDTEXT,
|
||||
\EmailValidator\EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
"example@[\n]"
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[::1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[::123.45.67.178]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_IPV6_GRPCOUNT,
|
||||
\EmailValidator\EmailValidator::RFC5322_IPV6_COLONSTRT,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6::2001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_IPV6_BADCHAR,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:z001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_IPV6_COLONEND,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5321_QUOTEDSTRING,
|
||||
),
|
||||
'"example"@example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_LOCAL_TOOLONG,
|
||||
),
|
||||
'too_long_localpart_too_long_localpart_too_long_localpart_too_long_localpart@example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_LABEL_TOOLONG,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_DOMAIN_TOOLONG,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
\EmailValidator\EmailValidator::RFC5322_TOOLONG,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_MX_RECORD,
|
||||
\EmailValidator\EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpar'
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
|
||||
require __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
@@ -31,5 +31,3 @@ for ($i = 0; $i < $iterations; $i++) {
|
||||
}
|
||||
$b = microtime(true);
|
||||
echo ($b - $a) . ' seconds with EmailValidator once instanced' . PHP_EOL;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
|
||||
require __DIR__ . '/../../bootstrap.php';
|
||||
require __DIR__ . '/../../../../isemail/is_email.php';
|
||||
|
||||
$iterations = 10000;
|
||||
|
||||
$testingMail = 'fabien@symfony.com';
|
||||
echo 'Testing ' . $iterations . ' iterations with ' . $testingMail . PHP_EOL;
|
||||
|
||||
$a = microtime(true);
|
||||
for ($i = 0; $i < $iterations; $i++) {
|
||||
$isValid = is_email($testingMail);
|
||||
}
|
||||
$b = microtime(true);
|
||||
echo ($b - $a) . ' seconds with is_email' . PHP_EOL;
|
||||
|
||||
$a = microtime(true);
|
||||
for ($i = 0; $i < $iterations; $i++) {
|
||||
$validator = new EmailValidator();
|
||||
$isValid = $validator->isValid($testingMail);
|
||||
}
|
||||
$b = microtime(true);
|
||||
echo ($b - $a) . ' seconds with EmailValidator + instantiation' . PHP_EOL;
|
||||
|
||||
$a = microtime(true);
|
||||
$validator = new EmailValidator();
|
||||
for ($i = 0; $i < $iterations; $i++) {
|
||||
$isValid = $validator->isValid($testingMail);
|
||||
}
|
||||
$b = microtime(true);
|
||||
echo ($b - $a) . ' seconds with EmailValidator once instanced' . PHP_EOL;
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace egulias\Tests\EmailValidator;
|
||||
namespace Egulias\EmailValidator\Tests;
|
||||
|
||||
use egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
|
||||
class EmailLexerTests extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -10,7 +10,7 @@ class EmailLexerTests extends \PHPUnit_Framework_TestCase
|
||||
public function testLexerExtendsLib()
|
||||
{
|
||||
$lexer = new EmailLexer();
|
||||
$this->assertInstanceOf('JMS\Parser\AbstractLexer', $lexer);
|
||||
$this->assertInstanceOf('Doctrine\Common\Lexer\AbstractLexer', $lexer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,16 +22,18 @@ class EmailLexerTests extends \PHPUnit_Framework_TestCase
|
||||
$lexer = new EmailLexer();
|
||||
$lexer->setInput($str);
|
||||
$lexer->moveNext();
|
||||
$this->assertEquals($token, $lexer->token[0]);
|
||||
$lexer->moveNext();
|
||||
$this->assertEquals($token, $lexer->token['type']);
|
||||
}
|
||||
|
||||
public function testLexerForTab()
|
||||
{
|
||||
$lexer = new EmailLexer();
|
||||
$lexer->setInput("foo\tbar");
|
||||
$lexer->moveNext();
|
||||
$lexer->skipUntil(EmailLexer::S_HTAB);
|
||||
$lexer->moveNext();
|
||||
$this->assertEquals(EmailLexer::S_HTAB, $lexer->token[0]);
|
||||
$this->assertEquals(EmailLexer::S_HTAB, $lexer->token['type']);
|
||||
}
|
||||
|
||||
public function getTokens()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace egulias\Tests\EmailValidator;
|
||||
namespace Egulias\Tests\EmailValidator;
|
||||
|
||||
use egulias\EmailValidator\EmailParser;
|
||||
use Egulias\EmailValidator\EmailParser;
|
||||
|
||||
class EmailParserTests extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -10,6 +10,6 @@ class EmailParserTests extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$mock = $this->getMock('egulias\EmailValidator\EmailLexer');
|
||||
$parser = new EmailParser($mock);
|
||||
$this->assertInstanceOf('JMS\Parser\AbstractParser', $parser);
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace egulias\Tests\EmailValidator;
|
||||
namespace Egulias\Tests\EmailValidator;
|
||||
|
||||
use egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
|
||||
class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -35,13 +35,16 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
array('example@localhost'),
|
||||
array('fab\'ien@symfony.com'),
|
||||
array('example((example))@fakedfake.co.uk'),
|
||||
array('example@faked(fake).co.uk'),
|
||||
array('fabien+@symfony.com'),
|
||||
array('инфо@письмо.рф'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidEmails
|
||||
*/
|
||||
public function testInvalidEmails($email)
|
||||
public function testAInvalidEmails($email)
|
||||
{
|
||||
$this->assertFalse($this->validator->isValid($email));
|
||||
}
|
||||
@@ -50,7 +53,8 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array('example.@example.co.uk'),
|
||||
//array('(fabien_potencier@example.fr)'),
|
||||
array('example@example@example.co.uk'),
|
||||
array('(fabien_potencier@example.fr)'),
|
||||
array('example(example)example@example.co.uk'),
|
||||
array('.example@localhost'),
|
||||
array('ex\ample@localhost'),
|
||||
@@ -112,162 +116,147 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function getInvalidEmailsWithWarnings()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
),
|
||||
'example @example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
),
|
||||
'example@ example.co.uk'
|
||||
),
|
||||
array(array( EmailValidator::DEPREC_CFWS_NEAR_AT,), 'example @example.co.uk'),
|
||||
array(array( EmailValidator::DEPREC_CFWS_NEAR_AT,), 'example@ example.co.uk'),
|
||||
array(array( EmailValidator::CFWS_COMMENT,), 'example@example(examplecomment).co.uk'),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::CFWS_COMMENT,
|
||||
EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
),
|
||||
'example@example(examplecomment).co.uk'
|
||||
'example(examplecomment)@example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_QUOTEDSTRING,
|
||||
EmailValidator::CFWS_FWS,
|
||||
),
|
||||
"\"\t\"@example.co.uk"
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[127.0.0.1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5321_IPV6DEPRECATED,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370::]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_MAXGRPS,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334::]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_2X2XCOLON,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:1::1::1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMLIT_OBSDTEXT,
|
||||
EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
"example@[\n]"
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[::1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[::123.45.67.178]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_IPV6_COLONSTRT,
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_GRPCOUNT,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6::2001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_BADCHAR,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:z001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_IPV6_COLONEND,
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_QUOTEDSTRING,
|
||||
),
|
||||
'"example"@example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_LOCAL_TOOLONG,
|
||||
),
|
||||
'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,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAIN_TOOLONG,
|
||||
EmailValidator::RFC5322_TOOLONG,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocal'.
|
||||
'parttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'.
|
||||
'toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAIN_TOOLONG,
|
||||
EmailValidator::RFC5322_TOOLONG,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocal'.
|
||||
'parttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'.
|
||||
'toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpar'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::CFWS_COMMENT,
|
||||
EmailValidator::DEPREC_CFWS_NEAR_AT,
|
||||
),
|
||||
'example(examplecomment)@example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_QUOTEDSTRING,
|
||||
EmailValidator::CFWS_FWS,
|
||||
),
|
||||
"\"\t\"@example.co.uk"
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[127.0.0.1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5321_IPV6DEPRECATED,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370::]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_MAXGRPS,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334::]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_2X2XCOLON,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:1::1::1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMLIT_OBSDTEXT,
|
||||
EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
"example@[\n]"
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[::1]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAINLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[::123.45.67.178]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_IPV6_COLONSTRT,
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_GRPCOUNT,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6::2001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::RFC5322_IPV6_BADCHAR,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:z001:0db8:85a3:0000:0000:8a2e:0370:7334]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_IPV6_COLONEND,
|
||||
EmailValidator::RFC5321_ADDRESSLITERAL,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:]'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5321_QUOTEDSTRING,
|
||||
),
|
||||
'"example"@example.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_LOCAL_TOOLONG,
|
||||
),
|
||||
'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,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.co.uk'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAIN_TOOLONG,
|
||||
EmailValidator::RFC5322_TOOLONG,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocal'.
|
||||
'parttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'.
|
||||
'toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'
|
||||
),
|
||||
array(
|
||||
array(
|
||||
EmailValidator::RFC5322_DOMAIN_TOOLONG,
|
||||
EmailValidator::RFC5322_TOOLONG,
|
||||
EmailValidator::DNSWARN_NO_RECORD,
|
||||
),
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocal'.
|
||||
'parttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart'.
|
||||
'toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpar'
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user