mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-02 17:34:26 +02:00
Throw compile error when using a modifier where it won't work. Fixes #526.
This commit is contained in:
@@ -1107,6 +1107,9 @@ class Template extends BaseCompiler {
|
|||||||
$this->tag_nocache = $this->tag_nocache | !$tagCompiler->isCacheable();
|
$this->tag_nocache = $this->tag_nocache | !$tagCompiler->isCacheable();
|
||||||
$_output = $tagCompiler->compile($args, $this, $parameter);
|
$_output = $tagCompiler->compile($args, $this, $parameter);
|
||||||
if ($_output !== false) {
|
if ($_output !== false) {
|
||||||
|
if (!empty($parameter['modifierlist'])) {
|
||||||
|
throw new CompilerException('No modifiers allowed on ' . $tag);
|
||||||
|
}
|
||||||
return $this->has_code && $_output !== true ? $_output : null;
|
return $this->has_code && $_output !== true ? $_output : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1114,9 +1117,13 @@ class Template extends BaseCompiler {
|
|||||||
|
|
||||||
// call to function previousely defined by {function} tag
|
// call to function previousely defined by {function} tag
|
||||||
if ($this->canCompileTemplateFunctionCall($tag)) {
|
if ($this->canCompileTemplateFunctionCall($tag)) {
|
||||||
|
|
||||||
|
if (!empty($parameter['modifierlist'])) {
|
||||||
|
throw new CompilerException('No modifiers allowed on ' . $tag);
|
||||||
|
}
|
||||||
|
|
||||||
$args['_attr']['name'] = "'{$tag}'";
|
$args['_attr']['name'] = "'{$tag}'";
|
||||||
$tagCompiler = $this->getTagCompiler('call');
|
$tagCompiler = $this->getTagCompiler('call');
|
||||||
// compile this tag
|
|
||||||
$_output = $tagCompiler === null ? false : $tagCompiler->compile($args, $this, $parameter);
|
$_output = $tagCompiler === null ? false : $tagCompiler->compile($args, $this, $parameter);
|
||||||
return $this->has_code ? $_output : null;
|
return $this->has_code ? $_output : null;
|
||||||
}
|
}
|
||||||
@@ -1157,6 +1164,9 @@ class Template extends BaseCompiler {
|
|||||||
|
|
||||||
// the default plugin handler is a handler of last resort, it may also handle not specifically registered tags.
|
// the default plugin handler is a handler of last resort, it may also handle not specifically registered tags.
|
||||||
if ($callback = $this->getPluginFromDefaultHandler($base_tag, Smarty::PLUGIN_COMPILER)) {
|
if ($callback = $this->getPluginFromDefaultHandler($base_tag, Smarty::PLUGIN_COMPILER)) {
|
||||||
|
if (!empty($parameter['modifierlist'])) {
|
||||||
|
throw new CompilerException('No modifiers allowed on ' . $base_tag);
|
||||||
|
}
|
||||||
$tagCompiler = new \Smarty\Compile\Tag\BCPluginWrapper($callback);
|
$tagCompiler = new \Smarty\Compile\Tag\BCPluginWrapper($callback);
|
||||||
return $tagCompiler->compile($args, $this, $parameter);
|
return $tagCompiler->compile($args, $this, $parameter);
|
||||||
}
|
}
|
||||||
|
@@ -324,4 +324,11 @@ class CompileIncludeTest extends PHPUnit_Smarty
|
|||||||
array("A{include file='include_spacing3.tpl'}B\nC", "AbarB\nC", '3_Newline3', $i++),
|
array("A{include file='include_spacing3.tpl'}B\nC", "AbarB\nC", '3_Newline3', $i++),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testModifierWrongPlace() {
|
||||||
|
$this->smarty->debugging = true;
|
||||||
|
$this->expectException(\Smarty\CompilerException::class);
|
||||||
|
$this->expectExceptionMessage('No modifiers allowed');
|
||||||
|
$this->smarty->fetch('include_with_modifier.tpl');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
{include|upper file="helloworld.tpl"}
|
Reference in New Issue
Block a user