DNS record check now passes if email address has no top-level domain (#355)

This commit is contained in:
KergeKacsa
2023-01-14 15:17:03 +01:00
committed by GitHub
parent db4c31490b
commit 3a85486b70
2 changed files with 15 additions and 3 deletions
+13 -2
View File
@@ -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());
}
}
}