mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-04 14:38:21 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cfa3d44471 | |||
| 2f38a470f9 | |||
| ade6887fd9 |
+5
-2
@@ -1,4 +1,7 @@
|
|||||||
/Tests export-ignore
|
|
||||||
/documentation export-ignore
|
/documentation export-ignore
|
||||||
|
/tests export-ignore
|
||||||
/.* export-ignore
|
/.* export-ignore
|
||||||
/phpunit.xml.dist
|
/phpunit.xml.dist export-ignore
|
||||||
|
/psalm.xml export-ignore
|
||||||
|
/psalm.baseline.xml export-ignore
|
||||||
|
/README.md export-ignore
|
||||||
|
|||||||
+4
-4
@@ -18,21 +18,21 @@
|
|||||||
"symfony/polyfill-intl-idn": "^1.10"
|
"symfony/polyfill-intl-idn": "^1.10"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"satooshi/php-coveralls": "^1.0.1",
|
"dominicsayers/isemail": "^3.0.7",
|
||||||
"phpunit/phpunit": "^4.8.36|^7.5.15",
|
"phpunit/phpunit": "^4.8.36|^7.5.15",
|
||||||
"dominicsayers/isemail": "^3.0.7"
|
"satooshi/php-coveralls": "^1.0.1"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Egulias\\EmailValidator\\": "EmailValidator"
|
"Egulias\\EmailValidator\\": "src"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Egulias\\Tests\\": "Tests"
|
"Egulias\\EmailValidator\\Tests\\": "tests"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,16 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<files psalm-version="3.8.3@389af1bfc739bfdff3f9e3dc7bd6499aee51a831">
|
<files psalm-version="3.8.3@389af1bfc739bfdff3f9e3dc7bd6499aee51a831">
|
||||||
<file src="EmailValidator/EmailLexer.php">
|
<file src="src/EmailLexer.php">
|
||||||
<DocblockTypeContradiction occurrences="1">
|
<DocblockTypeContradiction occurrences="1">
|
||||||
<code>self::$nullToken</code>
|
<code>self::$nullToken</code>
|
||||||
</DocblockTypeContradiction>
|
</DocblockTypeContradiction>
|
||||||
</file>
|
</file>
|
||||||
<file src="EmailValidator/Parser/Parser.php">
|
<file src="src/Parser/Parser.php">
|
||||||
<MissingReturnType occurrences="1">
|
<MissingReturnType occurrences="1">
|
||||||
<code>parse</code>
|
<code>parse</code>
|
||||||
</MissingReturnType>
|
</MissingReturnType>
|
||||||
</file>
|
</file>
|
||||||
<file src="EmailValidator/Validation/SpoofCheckValidation.php">
|
<file src="src/Validation/SpoofCheckValidation.php">
|
||||||
<UndefinedClass occurrences="2">
|
<UndefinedClass occurrences="2">
|
||||||
<code>Spoofchecker</code>
|
<code>Spoofchecker</code>
|
||||||
<code>Spoofchecker</code>
|
<code>Spoofchecker</code>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
errorBaseline="./psalm.baseline.xml"
|
errorBaseline="./psalm.baseline.xml"
|
||||||
>
|
>
|
||||||
<projectFiles>
|
<projectFiles>
|
||||||
<directory name="EmailValidator" />
|
<directory name="src" />
|
||||||
<ignoreFiles>
|
<ignoreFiles>
|
||||||
<directory name="vendor" />
|
<directory name="vendor" />
|
||||||
</ignoreFiles>
|
</ignoreFiles>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class LocalPart extends Parser
|
|||||||
$parseDQuote = true;
|
$parseDQuote = true;
|
||||||
$closingQuote = false;
|
$closingQuote = false;
|
||||||
$openedParenthesis = 0;
|
$openedParenthesis = 0;
|
||||||
|
$totalLength = 0;
|
||||||
|
|
||||||
while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) {
|
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']) {
|
if ($this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']) {
|
||||||
@@ -34,12 +35,13 @@ class LocalPart extends Parser
|
|||||||
$this->parseComments();
|
$this->parseComments();
|
||||||
$openedParenthesis += $this->getOpenedParenthesis();
|
$openedParenthesis += $this->getOpenedParenthesis();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||||
if ($openedParenthesis === 0) {
|
if ($openedParenthesis === 0) {
|
||||||
throw new UnopenedComment();
|
throw new UnopenedComment();
|
||||||
} else {
|
|
||||||
$openedParenthesis--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$openedParenthesis--;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->checkConsecutiveDots();
|
$this->checkConsecutiveDots();
|
||||||
@@ -57,11 +59,11 @@ class LocalPart extends Parser
|
|||||||
$this->parseFWS();
|
$this->parseFWS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$totalLength += strlen($this->lexer->token['value']);
|
||||||
$this->lexer->moveNext();
|
$this->lexer->moveNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
$prev = $this->lexer->getPrevious();
|
if ($totalLength > LocalTooLong::LOCAL_PART_LENGTH) {
|
||||||
if (strlen($prev['value']) > LocalTooLong::LOCAL_PART_LENGTH) {
|
|
||||||
$this->warnings[LocalTooLong::CODE] = new LocalTooLong();
|
$this->warnings[LocalTooLong::CODE] = new LocalTooLong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ use Egulias\EmailValidator\Warning\QuotedString;
|
|||||||
abstract class Parser
|
abstract class Parser
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \Egulias\EmailValidator\Warning\Warning[]
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $warnings = [];
|
protected $warnings = [];
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Egulias\Tests\EmailValidator;
|
namespace Egulias\EmailValidator\Tests\EmailValidator;
|
||||||
|
|
||||||
use Egulias\EmailValidator\EmailLexer;
|
use Egulias\EmailValidator\EmailLexer;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Egulias\Tests\EmailValidator;
|
namespace Egulias\EmailValidator\Tests\EmailValidator;
|
||||||
|
|
||||||
use Egulias\EmailValidator\EmailValidator;
|
use Egulias\EmailValidator\EmailValidator;
|
||||||
use Egulias\EmailValidator\Validation\EmailValidation;
|
use Egulias\EmailValidator\Validation\EmailValidation;
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Egulias\Tests\EmailValidator\Validation;
|
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||||
|
|
||||||
use Egulias\EmailValidator\EmailLexer;
|
use Egulias\EmailValidator\EmailLexer;
|
||||||
use Egulias\EmailValidator\Exception\NoDNSRecord;
|
use Egulias\EmailValidator\Exception\NoDNSRecord;
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Egulias\Tests\EmailValidator\Validation;
|
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||||
|
|
||||||
use Egulias\EmailValidator\EmailValidator;
|
use Egulias\EmailValidator\EmailValidator;
|
||||||
use Egulias\EmailValidator\Validation\DNSCheckValidation;
|
use Egulias\EmailValidator\Validation\DNSCheckValidation;
|
||||||
@@ -27,7 +27,7 @@ class IsEmailFunctionTests extends TestCase
|
|||||||
|
|
||||||
public function isEmailTestSuite()
|
public function isEmailTestSuite()
|
||||||
{
|
{
|
||||||
$testSuite = dirname(__FILE__) . '/../../resources/is_email_tests.xml';
|
$testSuite = __DIR__ . '/../../resources/is_email_tests.xml';
|
||||||
$document = new \DOMDocument();
|
$document = new \DOMDocument();
|
||||||
$document->load($testSuite);
|
$document->load($testSuite);
|
||||||
$elements = $document->getElementsByTagName('test');
|
$elements = $document->getElementsByTagName('test');
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Egulias\Tests\EmailValidator\Validation;
|
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||||
|
|
||||||
use Egulias\EmailValidator\EmailLexer;
|
use Egulias\EmailValidator\EmailLexer;
|
||||||
use Egulias\EmailValidator\Exception\CommaInDomain;
|
use Egulias\EmailValidator\Exception\CommaInDomain;
|
||||||
@@ -18,7 +18,7 @@ class MultipleValidationWithAndTest extends TestCase
|
|||||||
public function testUsesAndLogicalOperation()
|
public function testUsesAndLogicalOperation()
|
||||||
{
|
{
|
||||||
$lexer = new EmailLexer();
|
$lexer = new EmailLexer();
|
||||||
$validationTrue = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
$validationTrue = $this->getMockBuilder(EmailValidation::class)->getMock();
|
||||||
$validationTrue->expects($this->any())->method("isValid")->willReturn(true);
|
$validationTrue->expects($this->any())->method("isValid")->willReturn(true);
|
||||||
$validationTrue->expects($this->any())->method("getWarnings")->willReturn([]);
|
$validationTrue->expects($this->any())->method("getWarnings")->willReturn([]);
|
||||||
$validationFalse = $this->getMockBuilder(EmailValidation::class)->getMock();
|
$validationFalse = $this->getMockBuilder(EmailValidation::class)->getMock();
|
||||||
@@ -60,7 +60,7 @@ class MultipleValidationWithAndTest extends TestCase
|
|||||||
$expectedResult = array_merge($warnings1, $warnings2);
|
$expectedResult = array_merge($warnings1, $warnings2);
|
||||||
|
|
||||||
$lexer = new EmailLexer();
|
$lexer = new EmailLexer();
|
||||||
$validation1 = $this->getMockBuilder("Egulias\\EmailValidator\\Validation\\EmailValidation")->getMock();
|
$validation1 = $this->getMockBuilder(EmailValidation::class)->getMock();
|
||||||
$validation1->expects($this->any())->method("isValid")->willReturn(true);
|
$validation1->expects($this->any())->method("isValid")->willReturn(true);
|
||||||
$validation1->expects($this->once())->method("getWarnings")->willReturn($warnings1);
|
$validation1->expects($this->once())->method("getWarnings")->willReturn($warnings1);
|
||||||
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Egulias\Tests\EmailValidator\Validation;
|
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||||
|
|
||||||
use Egulias\EmailValidator\EmailLexer;
|
use Egulias\EmailValidator\EmailLexer;
|
||||||
use Egulias\EmailValidator\Exception\NoDomainPart;
|
use Egulias\EmailValidator\Exception\NoDomainPart;
|
||||||
+6
-2
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Egulias\Tests\EmailValidator\Validation;
|
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||||
|
|
||||||
use Egulias\EmailValidator\EmailLexer;
|
use Egulias\EmailValidator\EmailLexer;
|
||||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||||
@@ -104,7 +104,7 @@ class RFCValidationTest extends TestCase
|
|||||||
|
|
||||||
public function testInvalidUTF8Email()
|
public function testInvalidUTF8Email()
|
||||||
{
|
{
|
||||||
$email = "\x80\x81\x82@\x83\x84\x85.\x86\x87\x88";
|
$email = "\x80\x81\x82@\x83\x84\x85.\x86\x87\x88";
|
||||||
$this->assertFalse($this->validator->isValid($email, $this->lexer));
|
$this->assertFalse($this->validator->isValid($email, $this->lexer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,6 +265,10 @@ class RFCValidationTest extends TestCase
|
|||||||
[LocalTooLong::CODE,],
|
[LocalTooLong::CODE,],
|
||||||
'too_long_localpart_too_long_localpart_too_long_localpart_too_long_localpart@invalid.example.com'
|
'too_long_localpart_too_long_localpart_too_long_localpart_too_long_localpart@invalid.example.com'
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
[LocalTooLong::CODE],
|
||||||
|
'too_long_localpart_too_long_localpart_123_too_long_localpart_too_long_localpart@example.com'
|
||||||
|
],
|
||||||
[
|
[
|
||||||
[LabelTooLong::CODE,],
|
[LabelTooLong::CODE,],
|
||||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.co.uk'
|
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.co.uk'
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Egulias\Tests\EmailValidator\Validation;
|
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||||
|
|
||||||
use Egulias\EmailValidator\EmailLexer;
|
use Egulias\EmailValidator\EmailLexer;
|
||||||
use Egulias\EmailValidator\Validation\SpoofCheckValidation;
|
use Egulias\EmailValidator\Validation\SpoofCheckValidation;
|
||||||
Reference in New Issue
Block a user