PHP8.2 compatibility : Remove HTML-ENTITIES parameter

This commit is contained in:
Progi1984
2022-11-18 09:52:47 +01:00
parent afbcf3250d
commit 9fee14e7af
3 changed files with 5 additions and 3 deletions

View File

@@ -90,7 +90,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
} }
} }
// htmlentities() won't convert everything, so use mb_convert_encoding // htmlentities() won't convert everything, so use mb_convert_encoding
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set); $string = mb_convert_encoding($string, 'UTF-8', $char_set);
$string = htmlentities($string);
return htmlspecialchars_decode($string);
} }
// no MBString fallback // no MBString fallback
if ($_double_encode) { if ($_double_encode) {

View File

@@ -39,7 +39,7 @@ function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompi
case 'entity': case 'entity':
case 'htmlall': case 'htmlall':
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')'; return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
} }
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')'; return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')';
case 'html': case 'html':

View File

@@ -30,7 +30,7 @@ class PluginModifierStripTest extends PHPUnit_Smarty
{ {
// Some Unicode Spaces // Some Unicode Spaces
$string = " hello spaced       words "; $string = " hello spaced       words ";
$string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES"); $string = html_entity_decode($string, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, 'UTF-8');
$tpl = $this->smarty->createTemplate('string:{"' . $string . '"|strip}'); $tpl = $this->smarty->createTemplate('string:{"' . $string . '"|strip}');
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl)); $this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
} }