From 42884546cc743cc83f8153b7cc889381b0a69077 Mon Sep 17 00:00:00 2001 From: rechosen <rechosen@gmail.com> Date: Fri, 13 Sep 2013 12:05:20 +0200 Subject: [PATCH 1/3] [ticket/11843] The twig lexer fixes DEFINE variables with underscores again https://github.com/phpbb/phpbb3/pull/1708 accidentally stopped the twig lexer from fixing DEFINE variables with underscores in them. This commit restores that functionality. PHPBB3-11843 --- phpBB/phpbb/template/twig/lexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 8b72a06642..16a693cd7c 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -75,7 +75,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Fix tokens that may have inline variables (e.g. <!-- DEFINE $TEST = '{FOO}') $code = $this->fix_inline_variable_tokens(array( - 'DEFINE \$[a-zA-Z0-9]+ =', + 'DEFINE \$[a-zA-Z0-9_]+ =', 'INCLUDE', 'INCLUDEPHP', 'INCLUDEJS', From 45ecbae1edd32224dd6e2b1aaee5f289afddb7b9 Mon Sep 17 00:00:00 2001 From: rechosen <rechosen@gmail.com> Date: Fri, 13 Sep 2013 12:27:07 +0200 Subject: [PATCH 2/3] [ticket/11843] Add checking DEFINE variables with underscores to template_test To prevent the underscore in DEFINE variables from being forgotten again, the template tests now test INCLUDEing a file based on the contents of a DEFINE variable with underscores in it. PHPBB3-11843 --- tests/template/template_test.php | 2 +- tests/template/templates/include_define_variable.html | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 1649604492..c28c7a70bc 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -237,7 +237,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array('VARIABLE' => 'variable.html'), array(), array(), - 'variable.html', + 'variable.htmlvariable.html', ), array( 'include_loop_define.html', diff --git a/tests/template/templates/include_define_variable.html b/tests/template/templates/include_define_variable.html index aff9b574c2..fceeebf5df 100644 --- a/tests/template/templates/include_define_variable.html +++ b/tests/template/templates/include_define_variable.html @@ -1,2 +1,4 @@ <!-- DEFINE $DEF = '{VARIABLE}' --> <!-- INCLUDE {$DEF} --> +<!-- DEFINE $DEF_WITH_UNDERSCORES = '{VARIABLE}' --> +<!-- INCLUDE {$DEF_WITH_UNDERSCORES} --> From 658f6e204510b328509a0387eb9711617fdc3bee Mon Sep 17 00:00:00 2001 From: rechosen <rechosen@gmail.com> Date: Fri, 13 Sep 2013 13:48:00 +0200 Subject: [PATCH 3/3] [ticket/11843] Added newlines and included numbers in the DEFINE vars test Per suggestion of nickvergessen, I added newlines in the DEFINE variables with underscores test. Now if the test fails, it's easier to spot which part is failing. Also added a test for DEFINE variables containing numbers. PHPBB3-11843 --- tests/template/template_test.php | 2 +- tests/template/templates/include_define_variable.html | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/template/template_test.php b/tests/template/template_test.php index c28c7a70bc..2cca20f4c2 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -237,7 +237,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array('VARIABLE' => 'variable.html'), array(), array(), - 'variable.htmlvariable.html', + "variable.html\nvariable.html\nvariable.html", ), array( 'include_loop_define.html', diff --git a/tests/template/templates/include_define_variable.html b/tests/template/templates/include_define_variable.html index fceeebf5df..6052657c97 100644 --- a/tests/template/templates/include_define_variable.html +++ b/tests/template/templates/include_define_variable.html @@ -1,4 +1,8 @@ <!-- DEFINE $DEF = '{VARIABLE}' --> <!-- INCLUDE {$DEF} --> + <!-- DEFINE $DEF_WITH_UNDERSCORES = '{VARIABLE}' --> <!-- INCLUDE {$DEF_WITH_UNDERSCORES} --> + +<!-- DEFINE $DEF123 = '{VARIABLE}' --> +<!-- INCLUDE {$DEF123} -->