From 3ca17acb4aaf6add233390741d3ac5198a98d602 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 7 Dec 2012 16:09:05 +0100 Subject: [PATCH] added an exception when misusing macro calls (refs #922) --- lib/Twig/ExpressionParser.php | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/lib/Twig/ExpressionParser.php b/lib/Twig/ExpressionParser.php index 6a555e1..dc49c49 100644 --- a/lib/Twig/ExpressionParser.php +++ b/lib/Twig/ExpressionParser.php @@ -393,6 +393,10 @@ class Twig_ExpressionParser } if ($node instanceof Twig_Node_Expression_Name && null !== $alias = $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) { + if (!$arg instanceof Twig_Node_Expression_Constant) { + throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s")', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename()); + } + $node = new Twig_Node_Expression_MethodCall($node, 'get'.$arg->getAttribute('value'), $arguments, $lineno); $node->setAttribute('safe', true); -- 1.7.2.5