mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-31 12:40:28 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 68e418ec08 | |||
| ef615f1d74 | |||
| 563d0cdde5 | |||
| c7ab280976 | |||
| f46887bc48 |
@@ -5,7 +5,7 @@
|
||||
[](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master)
|
||||
[](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6)
|
||||
|
||||
## Suported RFCs ##
|
||||
## Supported RFCs ##
|
||||
|
||||
This library aims to support:
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,11 +115,12 @@ 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
|
||||
if (empty($dnsRecords)) {
|
||||
if (empty($dnsRecords) || !$dnsRecords) {
|
||||
$this->error = new NoDNSRecord();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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,7 @@ class RFCValidationTest extends TestCase
|
||||
['test@email<'],
|
||||
['test@email{'],
|
||||
['test@ '],
|
||||
['test@example.com []'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user