From ec24a245e713ec27accdd52a17c73d0bcb715347 Mon Sep 17 00:00:00 2001 From: Aaron Schmitz Date: Fri, 17 Aug 2012 18:03:52 -0500 Subject: [PATCH] Remove the weird exception handling from string.php. This handling can cause problems in JArrayHelper::sortObjects due to https://bugs.php.net/bug.php?id=50688. Iconv throws a notice if there is an illegal character regardless of whether ignore is set so this handling is pointless (and in fact broken since it will always fall back to IGNORE not TRANSLIT). Also, //TRANSLIT,IGNORE not //TRANSLIT//IGNORE will properly both transliterate and ignore. --- libraries/joomla/string/string.php | 37 +----------------------------- 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/libraries/joomla/string/string.php b/libraries/joomla/string/string.php index 89f1bd9dbe..ad62f8e800 100644 --- a/libraries/joomla/string/string.php +++ b/libraries/joomla/string/string.php @@ -709,23 +709,6 @@ public static function ucwords($str) return utf8_ucwords($str); } - /** - * Catch an error and throw an exception. - * - * @param integer $number Error level - * @param string $message Error message - * - * @return void - * - * @link https://bugs.php.net/bug.php?id=48147 - * - * @throw ErrorException - */ - private static function _iconvErrorHandler($number, $message) - { - throw new ErrorException($message, 0, $number); - } - /** * Transcode a string. * @@ -743,25 +726,7 @@ public static function transcode($source, $from_encoding, $to_encoding) { if (is_string($source)) { - set_error_handler(array(__CLASS__, '_iconvErrorHandler'), E_NOTICE); - try - { - /* - * "//TRANSLIT//IGNORE" is appended to the $to_encoding to ensure that when iconv comes - * across a character that cannot be represented in the target charset, it can - * be approximated through one or several similarly looking characters or ignored. - */ - $iconv = iconv($from_encoding, $to_encoding . '//TRANSLIT//IGNORE', $source); - } - catch (ErrorException $e) - { - /* - * "//IGNORE" is appended to the $to_encoding to ensure that when iconv comes - * across a character that cannot be represented in the target charset, it is ignored. - */ - $iconv = iconv($from_encoding, $to_encoding . '//IGNORE', $source); - } - restore_error_handler(); + $iconv = @iconv($from_encoding, $to_encoding . '//TRANSLIT,IGNORE', $source); return $iconv; }