mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-19 15:20:41 +00:00
DNS record check now passes if email address has no top-level domain (#355)
This commit is contained in:
@@ -123,9 +123,20 @@ class DNSCheckValidation implements EmailValidation
|
||||
{
|
||||
$variant = INTL_IDNA_VARIANT_UTS46;
|
||||
|
||||
$host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.';
|
||||
$host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.');
|
||||
|
||||
return $this->validateDnsRecords($host);
|
||||
$hostParts = explode('.', $host);
|
||||
$host = array_pop($hostParts);
|
||||
|
||||
while (count($hostParts) > 0) {
|
||||
$host = array_pop($hostParts) . '.' . $host;
|
||||
|
||||
if ($this->validateDnsRecords($host)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ class DNSCheckValidationTest extends TestCase
|
||||
return [
|
||||
// dot-atom
|
||||
['Abc@ietf.org'],
|
||||
['Abc@fake.ietf.org'],
|
||||
['ABC@ietf.org'],
|
||||
['Abc.123@ietf.org'],
|
||||
['user+mailbox/department=shipping@ietf.org'],
|
||||
@@ -149,4 +150,4 @@ class DNSCheckValidationTest extends TestCase
|
||||
$validation->isValid('example@invalid.example.com', new EmailLexer());
|
||||
$this->assertEquals($expectedError, $validation->getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user