disallow {% set %}{% endset %}
authornikic <+@ni-po.com>
Wed, 22 Dec 2010 16:19:37 +0000 (17:19 +0100)
committerFabien Potencier <fabien.potencier@gmail.com>
Wed, 22 Dec 2010 17:04:45 +0000 (18:04 +0100)
lib/Twig/ExpressionParser.php
test/Twig/Tests/ExpressionParserTest.php

index 68f9a9d..01a6e70 100644 (file)
@@ -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;
index a6ec00b..d36c9fd 100644 (file)
@@ -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 %}')
         );
     }