mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-09-03 14:10:40 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cfa3d44471 | |||
| 2f38a470f9 | |||
| ade6887fd9 | |||
| 5065fafc8c |
+5
-2
@@ -1,4 +1,7 @@
|
||||
/Tests export-ignore
|
||||
/documentation export-ignore
|
||||
/tests 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"
|
||||
},
|
||||
"require-dev": {
|
||||
"satooshi/php-coveralls": "^1.0.1",
|
||||
"dominicsayers/isemail": "^3.0.7",
|
||||
"phpunit/phpunit": "^4.8.36|^7.5.15",
|
||||
"dominicsayers/isemail": "^3.0.7"
|
||||
"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\\": "Tests"
|
||||
"Egulias\\EmailValidator\\Tests\\": "tests"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="3.8.3@389af1bfc739bfdff3f9e3dc7bd6499aee51a831">
|
||||
<file src="EmailValidator/EmailLexer.php">
|
||||
<file src="src/EmailLexer.php">
|
||||
<DocblockTypeContradiction occurrences="1">
|
||||
<code>self::$nullToken</code>
|
||||
</DocblockTypeContradiction>
|
||||
</file>
|
||||
<file src="EmailValidator/Parser/Parser.php">
|
||||
<file src="src/Parser/Parser.php">
|
||||
<MissingReturnType occurrences="1">
|
||||
<code>parse</code>
|
||||
</MissingReturnType>
|
||||
</file>
|
||||
<file src="EmailValidator/Validation/SpoofCheckValidation.php">
|
||||
<file src="src/Validation/SpoofCheckValidation.php">
|
||||
<UndefinedClass occurrences="2">
|
||||
<code>Spoofchecker</code>
|
||||
<code>Spoofchecker</code>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
errorBaseline="./psalm.baseline.xml"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="EmailValidator" />
|
||||
<directory name="src" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
|
||||
@@ -19,6 +19,7 @@ class LocalPart extends Parser
|
||||
$parseDQuote = true;
|
||||
$closingQuote = false;
|
||||
$openedParenthesis = 0;
|
||||
$totalLength = 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']) {
|
||||
@@ -34,12 +35,13 @@ class LocalPart extends Parser
|
||||
$this->parseComments();
|
||||
$openedParenthesis += $this->getOpenedParenthesis();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||
if ($openedParenthesis === 0) {
|
||||
throw new UnopenedComment();
|
||||
} else {
|
||||
$openedParenthesis--;
|
||||
}
|
||||
|
||||
$openedParenthesis--;
|
||||
}
|
||||
|
||||
$this->checkConsecutiveDots();
|
||||
@@ -57,11 +59,11 @@ class LocalPart extends Parser
|
||||
$this->parseFWS();
|
||||
}
|
||||
|
||||
$totalLength += strlen($this->lexer->token['value']);
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
$prev = $this->lexer->getPrevious();
|
||||
if (strlen($prev['value']) > LocalTooLong::LOCAL_PART_LENGTH) {
|
||||
if ($totalLength > LocalTooLong::LOCAL_PART_LENGTH) {
|
||||
$this->warnings[LocalTooLong::CODE] = new LocalTooLong();
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ use Egulias\EmailValidator\Warning\QuotedString;
|
||||
abstract class Parser
|
||||
{
|
||||
/**
|
||||
* @var \Egulias\EmailValidator\Warning\Warning[]
|
||||
* @var array
|
||||
*/
|
||||
protected $warnings = [];
|
||||
|
||||
@@ -170,7 +170,7 @@ abstract class Parser
|
||||
{
|
||||
$previous = $this->lexer->getPrevious();
|
||||
|
||||
if ($previous['type'] === EmailLexer::S_BACKSLASH
|
||||
if ($previous && $previous['type'] === EmailLexer::S_BACKSLASH
|
||||
&&
|
||||
$this->lexer->token['type'] !== EmailLexer::GENERIC
|
||||
) {
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\Tests\EmailValidator;
|
||||
namespace Egulias\EmailValidator\Tests\EmailValidator;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\Tests\EmailValidator;
|
||||
namespace Egulias\EmailValidator\Tests\EmailValidator;
|
||||
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\EmailValidation;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\Tests\EmailValidator\Validation;
|
||||
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\NoDNSRecord;
|
||||
@@ -24,7 +24,7 @@ class DNSCheckValidationTest extends TestCase
|
||||
['"Abc@def"@example.com'],
|
||||
['"Fred\ Bloggs"@example.com'],
|
||||
['"Joe.\\Blow"@example.com'],
|
||||
|
||||
|
||||
// unicide
|
||||
['ñandu.cl'],
|
||||
];
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\Tests\EmailValidator\Validation;
|
||||
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\DNSCheckValidation;
|
||||
@@ -27,7 +27,7 @@ class IsEmailFunctionTests extends TestCase
|
||||
|
||||
public function isEmailTestSuite()
|
||||
{
|
||||
$testSuite = dirname(__FILE__) . '/../../resources/is_email_tests.xml';
|
||||
$testSuite = __DIR__ . '/../../resources/is_email_tests.xml';
|
||||
$document = new \DOMDocument();
|
||||
$document->load($testSuite);
|
||||
$elements = $document->getElementsByTagName('test');
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\Tests\EmailValidator\Validation;
|
||||
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\CommaInDomain;
|
||||
@@ -18,7 +18,7 @@ class MultipleValidationWithAndTest extends TestCase
|
||||
public function testUsesAndLogicalOperation()
|
||||
{
|
||||
$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("getWarnings")->willReturn([]);
|
||||
$validationFalse = $this->getMockBuilder(EmailValidation::class)->getMock();
|
||||
@@ -60,7 +60,7 @@ class MultipleValidationWithAndTest extends TestCase
|
||||
$expectedResult = array_merge($warnings1, $warnings2);
|
||||
|
||||
$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->once())->method("getWarnings")->willReturn($warnings1);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\Tests\EmailValidator\Validation;
|
||||
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\NoDomainPart;
|
||||
+6
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\Tests\EmailValidator\Validation;
|
||||
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
@@ -104,7 +104,7 @@ class RFCValidationTest extends TestCase
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -265,6 +265,10 @@ class RFCValidationTest extends TestCase
|
||||
[LocalTooLong::CODE,],
|
||||
'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,],
|
||||
'example@toolonglocalparttoolonglocalparttoolonglocalparttoolonglocalpart.co.uk'
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\Tests\EmailValidator\Validation;
|
||||
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Validation\SpoofCheckValidation;
|
||||
Reference in New Issue
Block a user