diff --git a/src/Compiler/Template.php b/src/Compiler/Template.php index 9bf22fc87..741540201 100644 --- a/src/Compiler/Template.php +++ b/src/Compiler/Template.php @@ -1107,6 +1107,9 @@ private function compileTag2($tag, $args, $parameter) { $this->tag_nocache = $this->tag_nocache | !$tagCompiler->isCacheable(); $_output = $tagCompiler->compile($args, $this, $parameter); if ($_output !== false) { + if (!empty($parameter['modifierlist'])) { + throw new CompilerException('No modifiers allowed on ' . $tag); + } return $this->has_code && $_output !== true ? $_output : null; } } @@ -1114,9 +1117,13 @@ private function compileTag2($tag, $args, $parameter) { // call to function previousely defined by {function} tag if ($this->canCompileTemplateFunctionCall($tag)) { + + if (!empty($parameter['modifierlist'])) { + throw new CompilerException('No modifiers allowed on ' . $tag); + } + $args['_attr']['name'] = "'{$tag}'"; $tagCompiler = $this->getTagCompiler('call'); - // compile this tag $_output = $tagCompiler === null ? false : $tagCompiler->compile($args, $this, $parameter); return $this->has_code ? $_output : null; } @@ -1157,6 +1164,9 @@ private function compileTag2($tag, $args, $parameter) { // 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 (!empty($parameter['modifierlist'])) { + throw new CompilerException('No modifiers allowed on ' . $base_tag); + } $tagCompiler = new \Smarty\Compile\Tag\BCPluginWrapper($callback); return $tagCompiler->compile($args, $this, $parameter); } diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php index f9c71d20d..8a7cb78e5 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php @@ -324,4 +324,11 @@ public function dataTestSpacing() 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'); + } } diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_with_modifier.tpl b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_with_modifier.tpl new file mode 100644 index 000000000..15dd825da --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/Include/templates/include_with_modifier.tpl @@ -0,0 +1 @@ +{include|upper file="helloworld.tpl"} \ No newline at end of file