mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-02 09:24:28 +02:00
* Don't lower tags until they are used for extensions so custom tags can be case-sensitive.
This commit is contained in:
committed by
Simon Wisselink
parent
50dd6856c5
commit
46f96877b1
@@ -464,7 +464,7 @@ class Template extends BaseCompiler {
|
||||
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 @@ class Template extends BaseCompiler {
|
||||
* @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 @@ class Template extends BaseCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
// call to function previousely defined by {function} tag
|
||||
// call to function previously defined by {function} tag
|
||||
if ($this->canCompileTemplateFunctionCall($tag)) {
|
||||
|
||||
if (!empty($parameter['modifierlist'])) {
|
||||
|
@@ -261,6 +261,8 @@ class Security {
|
||||
* @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;
|
||||
|
@@ -39,6 +39,17 @@ class RegisterFunctionTest extends PHPUnit_Smarty
|
||||
$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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user