diff options
| author | Simon Wisselink <s.wisselink@iwink.nl> | 2023-03-24 12:19:34 +0100 |
|---|---|---|
| committer | Simon Wisselink <s.wisselink@iwink.nl> | 2023-03-24 12:19:34 +0100 |
| commit | e75165565e9e5956a73365c24d650ba40570ae72 (patch) | |
| tree | 76af3ede12001300a9fa38aac523049354794363 /tests | |
| parent | 3d2a8dc5fdc5227bcac6ada2becc9eebde417ace (diff) | |
| download | smarty-e75165565e9e5956a73365c24d650ba40570ae72.tar.gz smarty-e75165565e9e5956a73365c24d650ba40570ae72.tar.bz2 smarty-e75165565e9e5956a73365c24d650ba40570ae72.zip | |
Implement fix and tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php | 21 | ||||
| -rw-r--r-- | tests/UnitTests/TemplateSource/ValueTests/Operators/templates_c/.gitignore | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php index 309a71ab..073f9fcf 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php @@ -237,4 +237,25 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty $this->assertEquals("sma'rty@»example«.com", $this->smarty->fetch($tpl)); Smarty::$_MBSTRING = true; } + + public function testTemplateLiteralBackticks() + { + $tpl = $this->smarty->createTemplate('string:{"`Hello, World!`"|escape:"javascript"}'); + $this->assertEquals("\\`Hello, World!\\`", $this->smarty->fetch($tpl)); + } + + public function testTemplateLiteralInterpolation() + { + $tpl = $this->smarty->createTemplate('string:{$vector|escape:"javascript"}'); + $this->smarty->assign('vector', "`Hello, \${name}!`"); + $this->assertEquals("\\`Hello, \\\$\\{name}!\\`", $this->smarty->fetch($tpl)); + } + + public function testTemplateLiteralBackticksAndInterpolation() + { + $this->smarty->assign('vector', '`${alert(`Hello, ${name}!`)}${`\n`}`'); + $tpl = $this->smarty->createTemplate('string:{$vector|escape:"javascript"}'); + $this->assertEquals("\\`\\\$\\{alert(\\`Hello, \\\$\\{name}!\\`)}\\\$\\{\\`\\\\n\\`}\\`", $this->smarty->fetch($tpl)); + } + } diff --git a/tests/UnitTests/TemplateSource/ValueTests/Operators/templates_c/.gitignore b/tests/UnitTests/TemplateSource/ValueTests/Operators/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/TemplateSource/ValueTests/Operators/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* |
