Compare commits

...

6 Commits

Author SHA1 Message Date
David 5fa792ad18 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>
2020-10-31 21:37:35 +01:00
Eduardo Gulias Davis 68e418ec08 fix #217 (#266) 2020-09-26 17:48:38 +02:00
Phil Davis ef615f1d74 Minor typos (#265) 2020-09-26 16:40:57 +02:00
kishor 563d0cdde5 Issue-257: Fix PHP 7.3 compatibility issues. (#264) 2020-09-19 16:37:56 +02:00
zloKOMAtic c7ab280976 Update UnclosedComment.php (#263) 2020-09-19 16:37:41 +02:00
Eduardo Gulias Davis f46887bc48 Fix #260 with workaround (#261) 2020-09-06 15:44:32 +02:00
9 changed files with 19 additions and 10 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
+1 -1
View File
@@ -5,7 +5,7 @@
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/egulias/EmailValidator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6/small.png)](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6)
## Suported RFCs ##
## Supported RFCs ##
This library aims to support:
+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 -1
View File
@@ -5,5 +5,5 @@ namespace Egulias\EmailValidator\Exception;
class UnclosedComment extends InvalidEmail
{
const CODE = 146;
const REASON = "No colosing comment token found";
const REASON = "No closing comment token found";
}
+4
View File
@@ -198,6 +198,9 @@ class DomainPart extends Parser
$domain .= $this->lexer->token['value'];
$this->lexer->moveNext();
if ($this->lexer->token['type'] === EmailLexer::S_SP) {
throw new CharNotAllowed();
}
} while (null !== $this->lexer->token['type']);
return $domain;
@@ -332,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,
+3 -5
View File
@@ -97,10 +97,7 @@ class DNSCheckValidation implements EmailValidation
*/
protected function checkDns($host)
{
$variant = INTL_IDNA_VARIANT_2003;
if (defined('INTL_IDNA_VARIANT_UTS46')) {
$variant = INTL_IDNA_VARIANT_UTS46;
}
$variant = INTL_IDNA_VARIANT_UTS46;
$host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.';
@@ -118,7 +115,8 @@ class DNSCheckValidation implements EmailValidation
private function validateDnsRecords($host)
{
// Get all MX, A and AAAA DNS records for host
$dnsRecords = dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA);
// Using @ as workaround to fix https://bugs.php.net/bug.php?id=73149
$dnsRecords = @dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA);
// No MX, A or AAAA DNS records
+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),
@@ -27,7 +27,7 @@ class DNSCheckValidationTest extends TestCase
['"Fred\ Bloggs"@ietf.org'],
['"Joe.\\Blow"@ietf.org'],
// unicide
// unicode
['ñandu.cl'],
];
}
@@ -106,4 +106,4 @@ class DNSCheckValidationTest extends TestCase
$validation->isValid("example@invalid.example.com", new EmailLexer());
$this->assertEquals($expectedError, $validation->getError());
}
}
}
@@ -167,6 +167,8 @@ class RFCValidationTest extends TestCase
['test@email<'],
['test@email{'],
['test@ '],
['test@example.com []'],
["test@example.com'"],
];
}
@@ -211,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'"],
];
}