aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-06-09 23:32:39 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2013-06-09 23:32:39 -0500
commit87cc8af26565dc1547383aa8c969cc5be48f0944 (patch)
tree77d133bb3214ae9515cd1d448986d7042e8e3b87 /phpBB/includes/template
parent1da4be04b021af62e24f91bf0f82849c78bd04b9 (diff)
downloadforums-87cc8af26565dc1547383aa8c969cc5be48f0944.tar
forums-87cc8af26565dc1547383aa8c969cc5be48f0944.tar.gz
forums-87cc8af26565dc1547383aa8c969cc5be48f0944.tar.bz2
forums-87cc8af26565dc1547383aa8c969cc5be48f0944.tar.xz
forums-87cc8af26565dc1547383aa8c969cc5be48f0944.zip
[feature/twig] Support our old INCLUDE statements (no quotes)
Better code for handling IF .blah PHPBB3-11598
Diffstat (limited to 'phpBB/includes/template')
-rw-r--r--phpBB/includes/template/twig/lexer.php36
1 files changed, 23 insertions, 13 deletions
diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php
index 45b97acf8c..70a21307ec 100644
--- a/phpBB/includes/template/twig/lexer.php
+++ b/phpBB/includes/template/twig/lexer.php
@@ -19,24 +19,34 @@ class phpbb_template_twig_lexer extends Twig_Lexer
{
protected function lexExpression()
{
+ parent::lexExpression();
+
+ // Last element parsed
+ $last_element = end($this->tokens);
+
+ /**
+ * Check for old fashioned INCLUDE statements without enclosed quotes
+ */
+ if ($last_element->getValue() === 'INCLUDE')
+ {
+ if (preg_match('#^\s*([a-zA-Z0-9_]+\.[a-zA-Z0-9]+)#', substr($this->code, $this->cursor), $match))
+ {
+ $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[1]));
+ $this->moveCursor($match[0]);
+ }
+ }
+
/**
* This is some compatibility code to continue supporting expressions such as:
* <!-- IF .blah -->
- *
- * This does not seem very efficient, but I have not been able to find a better
- * method which works properly (maybe lexData can do it better, @todo test this)
*/
- $last_element = end($this->tokens);
- if ($last_element->getValue() === '.')
+ if ($last_element->getValue() === 'IF')
{
- $last_element2 = prev($this->tokens);
-
- if ($last_element2->getValue() === 'IF')
- {
- array_pop($this->tokens);
- }
+ if (preg_match('#^\s*\.([a-zA-Z0-9\.]+)#', substr($this->code, $this->cursor), $match))
+ {
+ $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[1]));
+ $this->moveCursor($match[0]);
+ }
}
-
- parent::lexExpression();
}
}