Skip to content

Commit

Permalink
Update functions.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSheer committed Sep 22, 2017
1 parent d42e1c9 commit 4f506f2
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions includes/functions.php
Expand Up @@ -944,26 +944,19 @@ function stk_filter_root_path($errfile)
function html_entity_decode_utf8($string)
{
static $trans_tbl;

// replace numeric entities
if (@phpversion() < '7.0.0')
{
$string = preg_replace('~&#x([0-9a-f]+);~ei', '_code2utf8(hexdec("\\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', '_code2utf8(\\1)', $string);
}
else
{
// eval() sucks, but we must use preg_replace_callback() to support
// PHP 7.0, and custom BBcode replacement function is stored as a string

$replacement = '_code2utf8(hexdec("\\1"))';
$string = preg_replace_callback('|&#x([0-9a-f]+);|', function($matches) use($replacement) {eval('$str=' . $replacement); return $str;}, $string);
$replacement = '_code2utf8(\\1)';
$string = preg_replace_callback(
'|&#([0-9]+);|',
function ($matches) { return _code2utf8(hexdec($matches[1])); },
$string
);
}
$string = preg_replace_callback(
'|&#x([0-9a-f]+)|',
function ($matches) { return _code2utf8(hexdec($matches[1])); },
$string
);

$string = preg_replace_callback(
'|&#([0-9]+);|',
function ($matches) { return _code2utf8($matches[1]); },
$string
);

// replace literal entities
if (!isset($trans_tbl))
Expand Down

0 comments on commit 4f506f2

Please sign in to comment.