From 0fe552857468aa12097a74e08f51f5aaa983be07 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 15:20:12 -0400 Subject: Upgrade Twig library --- inc/lib/Twig/TokenParser/Sandbox.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'inc/lib/Twig/TokenParser/Sandbox.php') diff --git a/inc/lib/Twig/TokenParser/Sandbox.php b/inc/lib/Twig/TokenParser/Sandbox.php index 62e7f8f7..9457325a 100644 --- a/inc/lib/Twig/TokenParser/Sandbox.php +++ b/inc/lib/Twig/TokenParser/Sandbox.php @@ -35,6 +35,19 @@ class Twig_TokenParser_Sandbox extends Twig_TokenParser $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); + // in a sandbox tag, only include tags are allowed + if (!$body instanceof Twig_Node_Include) { + foreach ($body as $node) { + if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) { + continue; + } + + if (!$node instanceof Twig_Node_Include) { + throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $node->getLine(), $this->parser->getFilename()); + } + } + } + return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag()); } @@ -46,7 +59,7 @@ class Twig_TokenParser_Sandbox extends Twig_TokenParser /** * Gets the tag name associated with this token parser. * - * @param string The tag name + * @return string The tag name */ public function getTag() { -- cgit v1.3