Email addresses with single quote should not be valid (#268)

* Fixes issue for email addresses with single quote in domain part
* specify version in cli for older php versions

Co-authored-by: Eduardo Gulias Davis <eduardomgulias@gmail.com>
This commit is contained in:
David
2020-11-01 03:37:35 +07:00
committed by GitHub
parent 68e418ec08
commit 5fa792ad18
6 changed files with 9 additions and 2 deletions
+2 -1
View File
@@ -31,7 +31,7 @@ matrix:
install:
- if [ "$deps" = "low" ]; then composer update --prefer-lowest; else composer install; fi
- if [ "$psalm" = "yes" ]; then composer require --dev vimeo/psalm; fi
- if [ "$psalm" = "yes" ]; then composer require --dev vimeo/psalm:3.18.2; fi
before_script:
- mkdir -p build/logs
@@ -42,3 +42,4 @@ script:
after_script:
- php vendor/bin/coveralls
+2
View File
@@ -13,6 +13,7 @@ class EmailLexer extends AbstractLexer
const S_BACKSLASH = 92;
const S_DOT = 46;
const S_DQUOTE = 34;
const S_SQUOTE = 39;
const S_OPENPARENTHESIS = 49;
const S_CLOSEPARENTHESIS = 261;
const S_OPENBRACKET = 262;
@@ -58,6 +59,7 @@ class EmailLexer extends AbstractLexer
'/' => self::S_SLASH,
',' => self::S_COMMA,
'.' => self::S_DOT,
"'" => self::S_SQUOTE,
'"' => self::S_DQUOTE,
'-' => self::S_HYPHEN,
'::' => self::S_DOUBLECOLON,
+1
View File
@@ -335,6 +335,7 @@ class DomainPart extends Parser
{
$invalidDomainTokens = array(
EmailLexer::S_DQUOTE => true,
EmailLexer::S_SQUOTE => true,
EmailLexer::S_SEMICOLON => true,
EmailLexer::S_GREATERTHAN => true,
EmailLexer::S_LOWERTHAN => true,
+1 -1
View File
@@ -120,7 +120,7 @@ class DNSCheckValidation implements EmailValidation
// No MX, A or AAAA DNS records
if (empty($dnsRecords) || !$dnsRecords) {
if (empty($dnsRecords)) {
$this->error = new NoDNSRecord();
return false;
}
+1
View File
@@ -138,6 +138,7 @@ class EmailLexerTests extends TestCase
array(":", EmailLexer::S_COLON),
array(".", EmailLexer::S_DOT),
array("\"", EmailLexer::S_DQUOTE),
array("'", EmailLexer::S_SQUOTE),
array("-", EmailLexer::S_HYPHEN),
array("\\", EmailLexer::S_BACKSLASH),
array("/", EmailLexer::S_SLASH),
@@ -168,6 +168,7 @@ class RFCValidationTest extends TestCase
['test@email{'],
['test@ '],
['test@example.com []'],
["test@example.com'"],
];
}
@@ -212,6 +213,7 @@ class RFCValidationTest extends TestCase
[new CRNoLF(), "example@exa\rmple.co.uk"],
[new CRNoLF(), "example@[\r]"],
[new CRNoLF(), "exam\rple@example.co.uk"],
[new ExpectingATEXT(), "test@example.com'"],
];
}