diff --git a/changelog/930.md b/changelog/930.md new file mode 100644 index 000000000..d9af7c2a5 --- /dev/null +++ b/changelog/930.md @@ -0,0 +1 @@ +- Fix incorrect compilation of expressions when escape_html=true [#930](https://github.com/smarty-php/smarty/pull/930) \ No newline at end of file diff --git a/src/Compile/PrintExpressionCompiler.php b/src/Compile/PrintExpressionCompiler.php index 99a03901f..486512d4f 100644 --- a/src/Compile/PrintExpressionCompiler.php +++ b/src/Compile/PrintExpressionCompiler.php @@ -84,7 +84,7 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = } if ($compiler->getTemplate()->getSmarty()->escape_html) { - $output = "htmlspecialchars((string) {$output}, ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')"; + $output = "htmlspecialchars((string) ({$output}), ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')"; } }