From 1c3b4b2786c36aca9dadb8c1ceed3bc47024cf10 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Sun, 30 Jun 2024 13:20:41 +0200 Subject: [PATCH] Added some more unit tests and a changelog entry. --- changelog/1030.md | 1 + .../A_Core/AutoEscape/AutoEscapeTest.php | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 changelog/1030.md 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)); + } + }