mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-01 13:07:22 +00:00
Do not allow : as macro definition separator
This commit is contained in:
@@ -735,7 +735,7 @@ class ExpressionParser
|
||||
}
|
||||
|
||||
$name = null;
|
||||
if ($namedArguments && (($token = $stream->nextIf(Token::OPERATOR_TYPE, '=')) || ($token = $stream->nextIf(Token::PUNCTUATION_TYPE, ':')))) {
|
||||
if ($namedArguments && (($token = $stream->nextIf(Token::OPERATOR_TYPE, '=')) || (!$definition && $token = $stream->nextIf(Token::PUNCTUATION_TYPE, ':')))) {
|
||||
if (!$value instanceof NameExpression) {
|
||||
throw new SyntaxError(\sprintf('A parameter name must be a string, "%s" given.', \get_class($value)), $token->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
"macro" tag does not support : as a separator in definition, only = is supported
|
||||
--TEMPLATE--
|
||||
{% macro test(foo: "foo") -%}
|
||||
{{ foo }}
|
||||
{%- endmacro %}
|
||||
--DATA--
|
||||
return []
|
||||
--EXCEPTION--
|
||||
Twig\Error\SyntaxError: Arguments must be separated by a comma. Unexpected token "punctuation" of value ":" ("punctuation" expected with value ",") in "index.twig" at line 2.
|
||||
Reference in New Issue
Block a user