diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 77fd1d232..05e296b02 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,6 +4,7 @@ bootstrap="./vendor/autoload.php" beStrictAboutOutputDuringTests="true" beStrictAboutTestsThatDoNotTestAnything="true" + failOnWarning="true" colors="true"> diff --git a/src/EmailAddress.php b/src/EmailAddress.php index 1e4b1033f..e03070deb 100644 --- a/src/EmailAddress.php +++ b/src/EmailAddress.php @@ -24,6 +24,7 @@ use function preg_match; use function strlen; use function strpos; +use function trim; use const INTL_IDNA_VARIANT_UTS46; @@ -453,6 +454,10 @@ protected function validateMXRecords() $reserved = false; } + if (! is_string($hostname) || ! trim($hostname)) { + continue; + } + if ( ! $res && (checkdnsrr($hostname, 'A') diff --git a/test/EmailAddressTest.php b/test/EmailAddressTest.php index db323c5ba..f94279853 100644 --- a/test/EmailAddressTest.php +++ b/test/EmailAddressTest.php @@ -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')); + } }