diff options
| author | Simon Wisselink <wisskid@users.noreply.github.com> | 2023-11-06 17:36:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-06 17:36:05 +0100 |
| commit | bc4e70f2c0a987e20dce9f77ec65e2e725630e18 (patch) | |
| tree | efb79ab8aa1ced63cf8279e5b6e68895b975e8c9 /tests | |
| parent | b28b85dbf48d6f82f48079065922a25eaa33088b (diff) | |
| download | smarty-bc4e70f2c0a987e20dce9f77ec65e2e725630e18.tar.gz smarty-bc4e70f2c0a987e20dce9f77ec65e2e725630e18.tar.bz2 smarty-bc4e70f2c0a987e20dce9f77ec65e2e725630e18.zip | |
Do not auto-html-escape custom function results. (#908)v5.0.0-rc2
Fixes #906
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php b/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php index f8ea54d5..f26f0f93 100644 --- a/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php +++ b/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php @@ -30,4 +30,35 @@ class AutoEscapeTest extends PHPUnit_Smarty $tpl->assign('foo', '<a@b.c>'); $this->assertEquals("<a@b.c>", $this->smarty->fetch($tpl)); } + + /** + * test 'escapeHtml' property + * @group issue906 + */ + public function testAutoEscapeDoesNotEscapeFunctionPlugins() + { + $this->smarty->registerPlugin( + \Smarty\Smarty::PLUGIN_FUNCTION, + 'horizontal_rule', + function ($params, $smarty) { return "<hr>"; } + ); + $tpl = $this->smarty->createTemplate('eval:{horizontal_rule}'); + $this->assertEquals("<hr>", $this->smarty->fetch($tpl)); + } + + /** + * test 'escapeHtml' property + * @group issue906 + */ + public function testAutoEscapeDoesNotEscapeBlockPlugins() + { + $this->smarty->registerPlugin( + \Smarty\Smarty::PLUGIN_BLOCK, + 'paragraphify', + function ($params, $content) { return $content == null ? null : "<p>".$content."</p>"; } + ); + $tpl = $this->smarty->createTemplate('eval:{paragraphify}hi{/paragraphify}'); + $this->assertEquals("<p>hi</p>", $this->smarty->fetch($tpl)); + } + } |
