diff --git a/changelog/1030.md b/changelog/1030.md new file mode 100644 index 000000000..f7cba021e --- /dev/null +++ b/changelog/1030.md @@ -0,0 +1 @@ +- Improvement of auto-escaping [#1030](https://github.com/smarty-php/smarty/pull/1030) \ No newline at end of file diff --git a/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php b/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php index dc921cbfb..4a4ef0662 100644 --- a/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php +++ b/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php @@ -96,4 +96,33 @@ public function testAutoEscapeSpecialEscape() { $tpl->assign('foo', 'aa bb'); $this->assertEquals("aa%20bb", $this->smarty->fetch($tpl)); } + + /** + * test autoescape + escape modifier = special escape + */ + public function testAutoEscapeSpecialEscape2() { + $tpl = $this->smarty->createTemplate('eval:{$foo|escape:\'url\'}'); + $tpl->assign('foo', '
'); + $this->assertEquals("%3CBR%3E", $this->smarty->fetch($tpl)); + } + + /** + * test autoescape + escape modifier = special escape + */ + public function testAutoEscapeSpecialEscape3() { + $tpl = $this->smarty->createTemplate('eval:{$foo|escape:\'htmlall\'}'); + $tpl->assign('foo', '
'); + $this->assertEquals("<BR>", $this->smarty->fetch($tpl)); + } + + + /** + * test autoescape + escape modifier = special escape + */ + public function testAutoEscapeSpecialEscape4() { + $tpl = $this->smarty->createTemplate('eval:{$foo|escape:\'javascript\'}'); + $tpl->assign('foo', '<\''); + $this->assertEquals("<\\'", $this->smarty->fetch($tpl)); + } + }