mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-04 21:44:57 +02:00
[ticket/11943] Throw an exception if DEFINE is setup improperly
PHPBB3-11943
This commit is contained in:
parent
6370970f13
commit
2e5117a71e
@ -30,6 +30,13 @@ class defineparser extends \Twig_TokenParser
|
||||
$stream->next();
|
||||
$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);
|
||||
} else {
|
||||
$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]';
|
||||
$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(), '');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user