mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[ticket/11943] Throw an exception if DEFINE is setup improperly
PHPBB3-11943
This commit is contained in:
@@ -30,6 +30,13 @@ class defineparser extends \Twig_TokenParser
|
|||||||
$stream->next();
|
$stream->next();
|
||||||
$value = $this->parser->getExpressionParser()->parseExpression();
|
$value = $this->parser->getExpressionParser()->parseExpression();
|
||||||
|
|
||||||
|
if ($value instanceof \Twig_Node_Expression_Name)
|
||||||
|
{
|
||||||
|
// This would happen if someone improperly formed their DEFINE syntax
|
||||||
|
// e.g. <!-- DEFINE $VAR = foo -->
|
||||||
|
throw new \Twig_Error_Syntax('Invalid DEFINE', $token->getLine(), $this->parser->getFilename());
|
||||||
|
}
|
||||||
|
|
||||||
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
|
||||||
} else {
|
} else {
|
||||||
$capture = true;
|
$capture = true;
|
||||||
|
@@ -561,4 +561,12 @@ EOT
|
|||||||
$expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
|
$expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
|
||||||
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification');
|
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Twig_Error_Syntax
|
||||||
|
*/
|
||||||
|
public function test_define_error()
|
||||||
|
{
|
||||||
|
$this->run_template('define_error.html', array(), array(), array(), '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user