Skip to content

Commit

Permalink
Merge pull request #123 from Saeven/bugfix/empty-deep-mx-checks
Browse files Browse the repository at this point in the history
Domains with bad MX configurations should not print warnings to page
  • Loading branch information
Ocramius authored Mar 8, 2022
2 parents cdea9a8 + 702c7d7 commit bdd503a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
bootstrap="./vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
failOnWarning="true"
colors="true">
<testsuites>
<testsuite name="laminas-validator Test Suite">
Expand Down
5 changes: 5 additions & 0 deletions src/EmailAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use function preg_match;
use function strlen;
use function strpos;
use function trim;

use const INTL_IDNA_VARIANT_UTS46;

Expand Down Expand Up @@ -453,6 +454,10 @@ protected function validateMXRecords()
$reserved = false;
}

if (! is_string($hostname) || ! trim($hostname)) {
continue;
}

if (
! $res
&& (checkdnsrr($hostname, 'A')
Expand Down
10 changes: 10 additions & 0 deletions test/EmailAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -924,4 +924,14 @@ public function testCanSetDomainCheckFlag(): void
$validator->useDomainCheck(false);
$this->assertFalse($validator->getDomainCheck());
}

public function testWillNotCheckEmptyDeepMxChecks(): void
{
$validator = new EmailAddress([
'useMxCheck' => true,
'useDeepMxCheck' => true,
]);

$this->assertFalse($validator->isValid('jon@example.com'));
}
}

0 comments on commit bdd503a

Please sign in to comment.