diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/README.md | 1 | ||||
-rw-r--r-- | libs/Zend/Validate/Hostname.php | 18 | ||||
-rw-r--r-- | libs/Zend/Validate/StringLength.php | 18 |
3 files changed, 30 insertions, 7 deletions
diff --git a/libs/README.md b/libs/README.md index 6488a45169..c705fdd7c9 100644 --- a/libs/README.md +++ b/libs/README.md @@ -28,3 +28,4 @@ third-party libraries: - in r3694, fix ZF-10888 and ZF-10835 - ZF-10871 - undefined variables when socket support disabled - fix #6980 ("Array to string conversion") in `Zend/Session/Exception.php` + - fix Zend/Validate using deprecated iconv_set_encoding() diff --git a/libs/Zend/Validate/Hostname.php b/libs/Zend/Validate/Hostname.php index 97779239f8..3540743db0 100644 --- a/libs/Zend/Validate/Hostname.php +++ b/libs/Zend/Validate/Hostname.php @@ -545,8 +545,15 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract if ((count($domainParts) > 1) && (strlen($value) >= 4) && (strlen($value) <= 254)) { $status = false; - $origenc = iconv_get_encoding('internal_encoding'); - iconv_set_encoding('internal_encoding', 'UTF-8'); + $origenc = PHP_VERSION_ID < 50600 + ? iconv_get_encoding('internal_encoding') + : ini_get('default_charset'); + if (PHP_VERSION_ID < 50600) { + iconv_set_encoding('internal_encoding', 'UTF-8'); + } else { + ini_set('default_charset', 'UTF-8'); + } + do { // First check TLD $matches = array(); @@ -642,7 +649,12 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract } } while (false); - iconv_set_encoding('internal_encoding', $origenc); + if (PHP_VERSION_ID < 50600) { + iconv_set_encoding('internal_encoding', $origenc); + } else { + ini_set('default_charset', $origenc); + } + // If the input passes as an Internet domain name, and domain names are allowed, then the hostname // passes validation if ($status && ($this->_options['allow'] & self::ALLOW_DNS)) { diff --git a/libs/Zend/Validate/StringLength.php b/libs/Zend/Validate/StringLength.php index 2151ad4ea5..364f665553 100644 --- a/libs/Zend/Validate/StringLength.php +++ b/libs/Zend/Validate/StringLength.php @@ -199,14 +199,24 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract public function setEncoding($encoding = null) { if ($encoding !== null) { - $orig = iconv_get_encoding('internal_encoding'); - $result = iconv_set_encoding('internal_encoding', $encoding); + $orig = PHP_VERSION_ID < 50600 + ? iconv_get_encoding('internal_encoding') + : ini_get('default_charset'); + if (PHP_VERSION_ID < 50600) { + $result = iconv_set_encoding('internal_encoding', $encoding); + } else { + $result = ini_set('default_charset', $encoding); + } if (!$result) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Given encoding not supported on this OS!'); } - iconv_set_encoding('internal_encoding', $orig); + if (PHP_VERSION_ID < 50600) { + iconv_set_encoding('internal_encoding', $orig); + } else { + ini_set('default_charset', $orig); + } } $this->_encoding = $encoding; |