From 8790f594151ca6a2010c6218e09d96df67173ad3 Mon Sep 17 00:00:00 2001 From: Lode Claassen Date: Tue, 10 Apr 2018 12:11:19 +0200 Subject: [PATCH] DNS check should convert unicode domains first (#166) * fix checkdnsrr not handling unicode domains properly * fix for php7.2 --- EmailValidator/Validation/DNSCheckValidation.php | 2 +- Tests/EmailValidator/Validation/DNSCheckValidationTest.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/EmailValidator/Validation/DNSCheckValidation.php b/EmailValidator/Validation/DNSCheckValidation.php index ecca1dd..a03a587 100644 --- a/EmailValidator/Validation/DNSCheckValidation.php +++ b/EmailValidator/Validation/DNSCheckValidation.php @@ -44,7 +44,7 @@ public function getWarnings() protected function checkDNS($host) { - $host = rtrim($host, '.') . '.'; + $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46), '.') . '.'; $Aresult = true; $MXresult = checkdnsrr($host, 'MX'); diff --git a/Tests/EmailValidator/Validation/DNSCheckValidationTest.php b/Tests/EmailValidator/Validation/DNSCheckValidationTest.php index 5063648..a664809 100644 --- a/Tests/EmailValidator/Validation/DNSCheckValidationTest.php +++ b/Tests/EmailValidator/Validation/DNSCheckValidationTest.php @@ -24,6 +24,9 @@ public function validEmailsProvider() ['"Abc@def"@example.com'], ['"Fred\ Bloggs"@example.com'], ['"Joe.\\Blow"@example.com'], + + // unicide + ['ñandu.cl'], ]; }