From: Joe Date: Fri, 7 Nov 2014 06:50:05 +0000 (+0100) Subject: Fixed deprecated preg_replace in php >= 5.3.0 with the /e flag in utf8 reports. X-Git-Tag: 2.3-final~91 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=a1a4dfb6ba6bc8104bf29cc02858c2e2eab1abfb Fixed deprecated preg_replace in php >= 5.3.0 with the /e flag in utf8 reports. --- diff --git a/reporting/includes/html_entity_decode_php4.php b/reporting/includes/html_entity_decode_php4.php index 1ecad710..27d5f36b 100644 --- a/reporting/includes/html_entity_decode_php4.php +++ b/reporting/includes/html_entity_decode_php4.php @@ -332,8 +332,17 @@ function html_entity_decode_php4($text_to_convert) { "<" => "<" ); $return_text = strtr($text_to_convert, $htmlentities_table); - $return_text = preg_replace('~&#x([0-9a-f]+);~ei', 'code_to_utf8(hexdec("\\1"))', $return_text); - $return_text = preg_replace('~&#([0-9]+);~e', 'code_to_utf8(\\1)', $return_text); + + if (version_compare(PHP_VERSION, '5.3.0') >= 0) // 07.11.2014, from php 5.3.0 fixed deprecated preg_replace with the /e flag. Joe. + { + $return_text = preg_replace_callback('~&#x([0-9a-f]+);~i', function ($m){ return chr(hexdec($m[1]));}, $return_text); + $return_text = preg_replace_callback('~&#([0-9]+);~', function ($m){ return chr($m[1]);}, $return_text); + } + else + { + $return_text = preg_replace('~&#x([0-9a-f]+);~ei', 'code_to_utf8(hexdec("\\1"))', $return_text); + $return_text = preg_replace('~&#([0-9]+);~e', 'code_to_utf8(\\1)', $return_text); + } return $return_text; }