Skip to content

Commit

Permalink
PHP8.2 compatibility : Remove HTML-ENTITIES parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Nov 18, 2022
1 parent afbcf32 commit 9fee14e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion libs/plugins/modifier.escape.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
if ($_double_encode) {
Expand Down
2 changes: 1 addition & 1 deletion libs/plugins/modifiercompiler.unescape.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompi
case 'entity':
case 'htmlall':
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 ] . ')';
case 'html':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testUnicodeSpaces()
{
// Some Unicode Spaces
$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}');
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
}
Expand Down

0 comments on commit 9fee14e

Please sign in to comment.