From 7aa8f6461f1e85cf91931f56b95384e54fec07c2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 30 Oct 2013 13:05:28 +0100 Subject: [task/code-sniffer] Remove the IN_PHPBB check side-effect from class files. PHPBB3-11980 --- phpBB/phpbb/template/twig/lexer.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'phpBB/phpbb/template/twig/lexer.php') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index d832fbf84e..be53b3eb5b 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -9,14 +9,6 @@ namespace phpbb\template\twig; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - class lexer extends \Twig_Lexer { public function tokenize($code, $filename = null) -- cgit v1.2.1 From b49d3a1851330d64009c8050132e50b093172559 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 4 Nov 2013 12:21:12 -0600 Subject: [ticket/11943] Do not quote the value when it is exactly true, false, or null Quoting these can change the meaning of the value (e.g. 'false' == true) PHPBB3-11943 --- phpBB/phpbb/template/twig/lexer.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/phpbb/template/twig/lexer.php') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index be53b3eb5b..8c52fa65b2 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -129,6 +129,14 @@ class lexer extends \Twig_Lexer // Replace template variables with start/end to parse variables (' ~ TEST ~ '.html) $matches[2] = preg_replace('#{([a-zA-Z0-9_\.$]+)}#', "'~ \$1 ~'", $matches[2]); + // If the second item is exactly one of a few key words, + // do not quote it as it changes the meaning + // http://tracker.phpbb.com/browse/PHPBB3-11943 + if (in_array($matches[2], array('false', 'true', 'null'))) + { + return ""; + } + // Surround the matches in single quotes ('' ~ TEST ~ '.html') return ""; }; -- cgit v1.2.1 From da332aa0a5cbeabbcce5551ee955c701fc2a1d73 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 8 Nov 2013 19:55:16 -0600 Subject: [ticket/11943] Require stricter DEFINE statements for templates PHPBB3-11943 --- phpBB/phpbb/template/twig/lexer.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'phpBB/phpbb/template/twig/lexer.php') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 8c52fa65b2..efd6a0bd84 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -69,7 +69,7 @@ class lexer extends \Twig_Lexer // Fix tokens that may have inline variables (e.g. "; - } - // Surround the matches in single quotes ('' ~ TEST ~ '.html') return ""; }; -- cgit v1.2.1 From 6370970f13d58f617379da64efb1f88a522f3f03 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 8 Nov 2013 22:30:58 -0600 Subject: [ticket/11943] Split fix_inline_variable_tokens into 3 steps DEFINE shouldn't add/remove surrounding quotes, but must have the inline variable tokens fixed PHPBB3-11943 --- phpBB/phpbb/template/twig/lexer.php | 60 ++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'phpBB/phpbb/template/twig/lexer.php') diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index efd6a0bd84..f4efc58540 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -68,8 +68,20 @@ class lexer extends \Twig_Lexer ); // Fix tokens that may have inline variables (e.g. #', '', $code); + } + /** * Fix tokens that may have inline variables * - * E.g. "; + return ""; }; return preg_replace_callback('##', $callback, $code); } + /** + * Add surrounding quotes + * + * Last step to fix tokens that may have inline variables + * E.g. #', '', $code); + } + /** * Fix begin tokens (convert our BEGIN to Twig for) * -- cgit v1.2.1