aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2011-09-24 22:21:05 +0200
committerAndreas Fischer <bantu@phpbb.com>2011-09-24 22:21:05 +0200
commitd01c028c1c1aab04b5cf9c0cdc785c05e52e138a (patch)
treef8349f70853a7ac30bd528064f8f014008069cb1
parent5e768036f773e461283d0f65841d2ff0618ec7b7 (diff)
parente9392bbddebab4cca5f1c5debda40e6156de6aaf (diff)
downloadforums-d01c028c1c1aab04b5cf9c0cdc785c05e52e138a.tar
forums-d01c028c1c1aab04b5cf9c0cdc785c05e52e138a.tar.gz
forums-d01c028c1c1aab04b5cf9c0cdc785c05e52e138a.tar.bz2
forums-d01c028c1c1aab04b5cf9c0cdc785c05e52e138a.tar.xz
forums-d01c028c1c1aab04b5cf9c0cdc785c05e52e138a.zip
Merge remote-tracking branch 'cs278/ticket/10384' into develop
* cs278/ticket/10384: [ticket/10384] Language variable replacements should not check for var prefix. [ticket/10384] Update unit tests to test for failing variable.
-rw-r--r--phpBB/includes/template/filter.php5
-rw-r--r--tests/template/template_test.php10
-rw-r--r--tests/template/templates/lang.html2
3 files changed, 10 insertions, 7 deletions
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index f24c3f4d09..d8ea603efd 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -40,6 +40,7 @@ class phpbb_template_filter extends php_user_filter
const REGEX_NS = '[a-z_][a-z_0-9]+';
const REGEX_VAR = '[A-Z_][A-Z_0-9]+';
+ const REGEX_VAR_SUFFIX = '[A-Z_0-9]+';
const REGEX_TAG = '<!-- ([A-Z][A-Z_0-9]+)(?: (.*?) ?)?-->';
@@ -374,7 +375,7 @@ class phpbb_template_filter extends php_user_filter
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
if (strpos($text_blocks, '{L_') !== false)
{
- $text_blocks = preg_replace('#\{L_(' . self::REGEX_VAR . ')\}#', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); /**/?>", $text_blocks, -1, $replacements);
+ $text_blocks = preg_replace('#\{L_(' . self::REGEX_VAR_SUFFIX . ')\}#', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); /**/?>", $text_blocks, -1, $replacements);
return (bool) $replacements;
}
@@ -382,7 +383,7 @@ class phpbb_template_filter extends php_user_filter
// If a template variable already exist, it will be used in favor of it...
if (strpos($text_blocks, '{LA_') !== false)
{
- $text_blocks = preg_replace('#\{LA_(' . self::REGEX_VAR . '+)\}#', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); /**/?>", $text_blocks, -1, $replacements);
+ $text_blocks = preg_replace('#\{LA_(' . self::REGEX_VAR_SUFFIX . '+)\}#', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); /**/?>", $text_blocks, -1, $replacements);
return (bool) $replacements;
}
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 28eba05217..8ea21444f3 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -211,21 +211,21 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array(),
array(),
- "{ VARIABLE }\n{ VARIABLE }",
+ "{ VARIABLE }\n{ 1_VARIABLE }\n{ VARIABLE }\n{ 1_VARIABLE }",
),
array(
'lang.html',
- array('L_VARIABLE' => "Value'"),
+ array('L_VARIABLE' => "Value'", 'L_1_VARIABLE' => "1 O'Clock"),
array(),
array(),
- "Value'\nValue\'",
+ "Value'\n1 O'Clock\nValue\'\n1 O\'Clock",
),
array(
'lang.html',
- array('LA_VARIABLE' => "Value'"),
+ array('LA_VARIABLE' => "Value'", 'LA_1_VARIABLE' => "1 O'Clock"),
array(),
array(),
- "{ VARIABLE }\nValue'",
+ "{ VARIABLE }\n{ 1_VARIABLE }\nValue'\n1 O'Clock",
),
array(
'loop_nested_multilevel_ref.html',
diff --git a/tests/template/templates/lang.html b/tests/template/templates/lang.html
index 2b5ea1cafe..3eecc298cb 100644
--- a/tests/template/templates/lang.html
+++ b/tests/template/templates/lang.html
@@ -1,3 +1,5 @@
{L_VARIABLE}
+{L_1_VARIABLE}
{LA_VARIABLE}
+{LA_1_VARIABLE}