From 6d030c266a1a64ee41b20c3383fd39d5232506f8 Mon Sep 17 00:00:00 2001 From: nikic <+@ni-po.com> Date: Wed, 22 Dec 2010 17:19:37 +0100 Subject: [PATCH] disallow {% set %}{% endset %} --- lib/Twig/ExpressionParser.php | 13 ------------- test/Twig/Tests/ExpressionParserTest.php | 1 + 2 files changed, 1 insertions(+), 13 deletions(-) diff --git a/lib/Twig/ExpressionParser.php b/lib/Twig/ExpressionParser.php index 68f9a9d..01a6e70 100644 --- a/lib/Twig/ExpressionParser.php +++ b/lib/Twig/ExpressionParser.php @@ -315,13 +315,6 @@ class Twig_ExpressionParser { $targets = array(); while (true) { - if ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ')') || - $this->parser->getStream()->test(Twig_Token::VAR_END_TYPE) || - $this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) - { - break; - } - $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to'); if (in_array($token->getValue(), array('true', 'false', 'none'))) { throw new Twig_Error_Syntax($token->getValue() . ' cannot be assigned to'); @@ -341,12 +334,6 @@ class Twig_ExpressionParser { $targets = array(); while (true) { - if ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ')') || - $this->parser->getStream()->test(Twig_Token::VAR_END_TYPE) || - $this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) - { - break; - } $targets[] = $this->parseExpression(); if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ',')) { break; diff --git a/test/Twig/Tests/ExpressionParserTest.php b/test/Twig/Tests/ExpressionParserTest.php index a6ec00b..d36c9fd 100644 --- a/test/Twig/Tests/ExpressionParserTest.php +++ b/test/Twig/Tests/ExpressionParserTest.php @@ -32,6 +32,7 @@ class Twig_Tests_ExpressionParserTest extends PHPUnit_Framework_TestCase array('{% set 3 = "foo" %}'), array('{% set 1 + 2 = "foo" %}'), array('{% set "bar" = "foo" %}'), + array('{% set %}{% endset %}') ); } -- 1.7.2.5