diff --git a/bin/update_hostname_validator.php b/bin/update_hostname_validator.php index fab52c24e..49070cbb5 100644 --- a/bin/update_hostname_validator.php +++ b/bin/update_hostname_validator.php @@ -177,7 +177,9 @@ function getNewValidTlds($string) function getPunycodeDecoder() { if (function_exists('idn_to_utf8')) { - return 'idn_to_utf8'; + return function($domain) { + return idn_to_utf8($domain, 0, INTL_IDNA_VARIANT_UTS46); + }; } $hostnameValidator = new Hostname(); diff --git a/src/EmailAddress.php b/src/EmailAddress.php index d089f84c0..55c450eef 100644 --- a/src/EmailAddress.php +++ b/src/EmailAddress.php @@ -530,7 +530,7 @@ public function isValid($value) protected function idnToAscii($email) { if (extension_loaded('intl')) { - return (idn_to_ascii($email) ?: $email); + return (idn_to_ascii($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email); } return $email; } @@ -553,7 +553,7 @@ protected function idnToUtf8($email) // the source string in those cases. // But not when the source string is long enough. // Thus we default to source string ourselves. - return idn_to_utf8($email) ?: $email; + return idn_to_utf8($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email; } return $email; } diff --git a/src/File/Upload.php b/src/File/Upload.php index 55025f633..724a8987d 100644 --- a/src/File/Upload.php +++ b/src/File/Upload.php @@ -9,6 +9,7 @@ namespace Zend\Validator\File; +use Countable; use Zend\Validator\AbstractValidator; use Zend\Validator\Exception; @@ -109,7 +110,7 @@ public function getFiles($file = null) */ public function setFiles($files = []) { - if (count($files) === 0) { + if ((is_array($files) || $files instanceof Countable) && count($files) === 0) { $this->options['files'] = $_FILES; } else { $this->options['files'] = $files;