diff --git a/src/Compiler/Template.php b/src/Compiler/Template.php index 03ee51102..e584236a0 100644 --- a/src/Compiler/Template.php +++ b/src/Compiler/Template.php @@ -464,7 +464,7 @@ public function compileTemplateSource(\Smarty\Template $template, \Smarty\Compil public function compileTag($tag, $args, $parameter = []) { $this->prefixCodeStack[] = $this->prefix_code; $this->prefix_code = []; - $result = $this->compileTag2(strtolower($tag), $args, $parameter); + $result = $this->compileTag2($tag, $args, $parameter); $this->prefix_code = array_merge($this->prefix_code, array_pop($this->prefixCodeStack)); return $result; } @@ -591,6 +591,7 @@ public function processText($text) { * @return ?\Smarty\Compile\CompilerInterface tag compiler object or null if not found or untrusted by security policy */ public function getTagCompiler($tag): ?\Smarty\Compile\CompilerInterface { + $tag = strtolower($tag); if (isset($this->smarty->security_policy) && !$this->smarty->security_policy->isTrustedTag($tag, $this)) { return null; @@ -1114,7 +1115,7 @@ private function compileTag2($tag, $args, $parameter) { } } - // call to function previousely defined by {function} tag + // call to function previously defined by {function} tag if ($this->canCompileTemplateFunctionCall($tag)) { if (!empty($parameter['modifierlist'])) { diff --git a/src/Security.php b/src/Security.php index 46cddcee6..2f654d4ea 100644 --- a/src/Security.php +++ b/src/Security.php @@ -261,6 +261,8 @@ public function isTrustedStaticClassAccess($class_name, $params, $compiler) { * @return boolean true if tag is trusted */ public function isTrustedTag($tag_name, $compiler) { + $tag_name = strtolower($tag_name); + // check for internal always required tags if (in_array($tag_name, ['assign', 'call'])) { return true; diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php index 6aa912407..7c7385059 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php @@ -39,6 +39,17 @@ public function testRegisterFunction() $this->assertEquals('hello world 1', $this->smarty->fetch('eval:{testfunction value=1}')); } + /** + * test registerPlugin method for function case-sensitive + */ + public function testRegisterFunctionCaseInsensitive() + { + $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testFunction', 'myfunction'); + $this->assertEquals('myfunction', + $this->smarty->getRegisteredPlugin(Smarty::PLUGIN_FUNCTION, 'testFunction')[0]); + $this->assertEquals('hello world 1', $this->smarty->fetch('eval:{testFunction value=1}')); + } + /** * test registerPlugin method for function class */