mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-10 18:16:41 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| af864423f5 | |||
| 12f16f70aa | |||
| 0afaa6a3b6 | |||
| 5631c3fe2e | |||
| c383717824 | |||
| aabed98198 | |||
| 3b0fd01aa3 | |||
| 4efe697504 | |||
| 7a4c5714f5 | |||
| 0a26375a7a | |||
| 773fe5f4a3 | |||
| 4a209951ee | |||
| a8b0bab5aa | |||
| cc0b91f311 | |||
| 8092ecaeff | |||
| f19defb373 | |||
| 9a518fb1bd | |||
| 9b184605e8 | |||
| 7a4842c60f | |||
| 687ab6a66e | |||
| 116d4054fa |
+19
-3
@@ -1,3 +1,5 @@
|
|||||||
|
sudo: false
|
||||||
|
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
@@ -5,11 +7,25 @@ php:
|
|||||||
- 5.4
|
- 5.4
|
||||||
- 5.5
|
- 5.5
|
||||||
- 5.6
|
- 5.6
|
||||||
|
- 7.0
|
||||||
- hhvm
|
- hhvm
|
||||||
|
|
||||||
before_script:
|
env:
|
||||||
- wget http://getcomposer.org/composer.phar
|
global:
|
||||||
- php composer.phar install --dev --no-interaction
|
- deps=no
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
|
include:
|
||||||
|
- php: 5.3
|
||||||
|
env: deps=low
|
||||||
|
- php: 5.6
|
||||||
|
env: deps=high
|
||||||
|
|
||||||
|
install:
|
||||||
|
- if [ "$deps" = "no" ]; then composer install; fi
|
||||||
|
- if [ "$deps" = "low" ]; then composer update --prefer-lowest; fi
|
||||||
|
- if [ "$deps" = "high" ]; then composer update; fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- mkdir -p build/logs
|
- mkdir -p build/logs
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#EmailValidator#
|
#EmailValidator
|
||||||
[](https://travis-ci.org/egulias/EmailValidator) [](https://coveralls.io/r/egulias/EmailValidator?branch=master) [](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master) [](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6)
|
[](https://travis-ci.org/egulias/EmailValidator) [](https://coveralls.io/r/egulias/EmailValidator?branch=master) [](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master) [](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6)
|
||||||
=============================
|
=============================
|
||||||
With the help of
|
With the help of
|
||||||
|
|||||||
+5
-4
@@ -3,22 +3,23 @@
|
|||||||
"description": "A library for validating emails",
|
"description": "A library for validating emails",
|
||||||
"homepage": "https://github.com/egulias/EmailValidator",
|
"homepage": "https://github.com/egulias/EmailValidator",
|
||||||
"type": "Library",
|
"type": "Library",
|
||||||
"keywords": ["email", "validation", "validator"],
|
"keywords": ["email", "validation", "validator", "emailvalidation", "emailvalidator"],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{"name": "Eduardo Gulias Davis"}
|
{"name": "Eduardo Gulias Davis"}
|
||||||
],
|
],
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "1.3.x-dev"
|
"dev-master": "2.0.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">= 5.3.3",
|
"php": ">= 5.3.3",
|
||||||
"doctrine/lexer": "~1.0"
|
"doctrine/lexer": "~1.0,>=1.0.1"
|
||||||
},
|
},
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
"satooshi/php-coveralls": "dev-master"
|
"satooshi/php-coveralls": "dev-master",
|
||||||
|
"phpunit/phpunit": "~4.4"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
|
|||||||
Generated
+1009
-97
File diff suppressed because it is too large
Load Diff
@@ -75,8 +75,6 @@ class EmailLexer extends AbstractLexer
|
|||||||
'\0' => self::C_NUL,
|
'\0' => self::C_NUL,
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $invalidASCII = array(226 => 1,);
|
|
||||||
|
|
||||||
protected $hasInvalidTokens = false;
|
protected $hasInvalidTokens = false;
|
||||||
|
|
||||||
protected $previous;
|
protected $previous;
|
||||||
@@ -138,7 +136,8 @@ class EmailLexer extends AbstractLexer
|
|||||||
protected function getCatchablePatterns()
|
protected function getCatchablePatterns()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'[a-zA-Z_]+[46]?',
|
'[a-zA-Z_]+[46]?', //ASCII and domain literal
|
||||||
|
'[^\x00-\x7F]', //UTF-8
|
||||||
'[0-9]+',
|
'[0-9]+',
|
||||||
'\r\n',
|
'\r\n',
|
||||||
'::',
|
'::',
|
||||||
@@ -179,11 +178,6 @@ class EmailLexer extends AbstractLexer
|
|||||||
return self::INVALID;
|
return self::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isASCIIInvalid($value)) {
|
|
||||||
$this->hasInvalidTokens = true;
|
|
||||||
return self::INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::GENERIC;
|
return self::GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,19 +203,6 @@ class EmailLexer extends AbstractLexer
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $value
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function isASCIIInvalid($value)
|
|
||||||
{
|
|
||||||
if (isset($this->invalidASCII[ord($value)])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $value
|
* @param $value
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|||||||
@@ -104,9 +104,6 @@ class DomainPart extends Parser
|
|||||||
{
|
{
|
||||||
$domain = '';
|
$domain = '';
|
||||||
do {
|
do {
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_SEMICOLON) {
|
|
||||||
throw new \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
|
||||||
}
|
|
||||||
|
|
||||||
$prev = $this->lexer->getPrevious();
|
$prev = $this->lexer->getPrevious();
|
||||||
|
|
||||||
@@ -221,9 +218,6 @@ class DomainPart extends Parser
|
|||||||
return $addressLiteral;
|
return $addressLiteral;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $addressLiteral
|
|
||||||
*/
|
|
||||||
protected function checkIPV4Tag($addressLiteral)
|
protected function checkIPV4Tag($addressLiteral)
|
||||||
{
|
{
|
||||||
$matchesIP = array();
|
$matchesIP = array();
|
||||||
@@ -249,6 +243,17 @@ class DomainPart extends Parser
|
|||||||
|
|
||||||
protected function checkDomainPartExceptions($prev)
|
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 \InvalidArgumentException('ERR_EXPECTING_ATEXT');
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_COMMA) {
|
if ($this->lexer->token['type'] === EmailLexer::S_COMMA) {
|
||||||
throw new \InvalidArgumentException('ERR_COMMA_IN_DOMAIN');
|
throw new \InvalidArgumentException('ERR_COMMA_IN_DOMAIN');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,17 @@ class EmailLexerTests extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(EmailLexer::S_HTAB, $lexer->token['type']);
|
$this->assertEquals(EmailLexer::S_HTAB, $lexer->token['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLexerForUTF8()
|
||||||
|
{
|
||||||
|
$lexer = new EmailLexer();
|
||||||
|
$lexer->setInput("áÇ@bar.com");
|
||||||
|
$lexer->moveNext();
|
||||||
|
$lexer->moveNext();
|
||||||
|
$this->assertEquals(EmailLexer::GENERIC, $lexer->token['type']);
|
||||||
|
$lexer->moveNext();
|
||||||
|
$this->assertEquals(EmailLexer::GENERIC, $lexer->token['type']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testLexerSearchToken()
|
public function testLexerSearchToken()
|
||||||
{
|
{
|
||||||
$lexer = new EmailLexer();
|
$lexer = new EmailLexer();
|
||||||
@@ -111,15 +122,6 @@ class EmailLexerTests extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($lexer->find(EmailLexer::S_HTAB));
|
$this->assertTrue($lexer->find(EmailLexer::S_HTAB));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLexerHasInvalidTokens()
|
|
||||||
{
|
|
||||||
$lexer = new EmailLexer();
|
|
||||||
$lexer->setInput(chr(226));
|
|
||||||
$lexer->moveNext();
|
|
||||||
$lexer->moveNext();
|
|
||||||
$this->assertTrue($lexer->hasInvalidTokens());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTokens()
|
public function getTokens()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
@@ -152,7 +154,7 @@ class EmailLexerTests extends \PHPUnit_Framework_TestCase
|
|||||||
array('}', EmailLexer::S_CLOSEQBRACKET),
|
array('}', EmailLexer::S_CLOSEQBRACKET),
|
||||||
array('', EmailLexer::S_EMPTY),
|
array('', EmailLexer::S_EMPTY),
|
||||||
array(chr(31), EmailLexer::INVALID),
|
array(chr(31), EmailLexer::INVALID),
|
||||||
array(chr(226), EmailLexer::INVALID),
|
array(chr(226), EmailLexer::GENERIC),
|
||||||
array(chr(0), EmailLexer::C_NUL)
|
array(chr(0), EmailLexer::C_NUL)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function getValidEmails()
|
public function getValidEmails()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
array('â@iana.org'),
|
||||||
array('fabien@symfony.com'),
|
array('fabien@symfony.com'),
|
||||||
array('example@example.co.uk'),
|
array('example@example.co.uk'),
|
||||||
array('fabien_potencier@example.fr'),
|
array('fabien_potencier@example.fr'),
|
||||||
@@ -55,6 +56,13 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('"test\ test"@iana.org'),
|
array('"test\ test"@iana.org'),
|
||||||
array('""@iana.org'),
|
array('""@iana.org'),
|
||||||
array('"\""@iana.org'),
|
array('"\""@iana.org'),
|
||||||
|
array('müller@möller.de'),
|
||||||
|
array('test@email*'),
|
||||||
|
array('test@email!'),
|
||||||
|
array('test@email&'),
|
||||||
|
array('test@email^'),
|
||||||
|
array('test@email%'),
|
||||||
|
array('test@email$'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +77,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function getInvalidEmails()
|
public function getInvalidEmails()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
array('test@example.com test'),
|
||||||
array('user name@example.com'),
|
array('user name@example.com'),
|
||||||
array('user name@example.com'),
|
array('user name@example.com'),
|
||||||
array('example.@example.co.uk'),
|
array('example.@example.co.uk'),
|
||||||
@@ -109,6 +117,12 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('test@iana.org \r\n\r\n '),
|
array('test@iana.org \r\n\r\n '),
|
||||||
array('test@iana/icann.org'),
|
array('test@iana/icann.org'),
|
||||||
array('test@foo;bar.com'),
|
array('test@foo;bar.com'),
|
||||||
|
array('test;123@foobar.com'),
|
||||||
|
array('test@example..com'),
|
||||||
|
array('email.email@email."'),
|
||||||
|
array('test@email>'),
|
||||||
|
array('test@email<'),
|
||||||
|
array('test@email{'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user