diff options
-rw-r--r-- | phpBB/includes/template_compile.php | 6 | ||||
-rw-r--r-- | tests/template/template_test.php | 9 | ||||
-rw-r--r-- | tests/template/templates/loop_underscore.html | 21 |
3 files changed, 33 insertions, 3 deletions
diff --git a/phpBB/includes/template_compile.php b/phpBB/includes/template_compile.php index d9eda1d8c2..92695a54fa 100644 --- a/phpBB/includes/template_compile.php +++ b/phpBB/includes/template_compile.php @@ -23,13 +23,13 @@ if (!defined('IN_PHPBB')) */ class phpbb_template_filter extends php_user_filter { - const REGEX_NS = '[a-z][a-z_0-9]+'; + const REGEX_NS = '[a-z_][a-z_0-9]+'; - const REGEX_VAR = '[A-Z][A-Z_0-9]+'; + const REGEX_VAR = '[A-Z_][A-Z_0-9]+'; const REGEX_TAG = '<!-- ([A-Z][A-Z_0-9]+)(?: (.*?) ?)?-->'; - const REGEX_TOKENS = '~<!-- ([A-Z][A-Z_0-9]+)(?: (.*?) ?)?-->|{((?:[a-z][a-z_0-9]+\.)*\\$?[A-Z][A-Z_0-9]+)}~'; + const REGEX_TOKENS = '~<!-- ([A-Z][A-Z_0-9]+)(?: (.*?) ?)?-->|{((?:[a-z_][a-z_0-9]+\.)*\\$?[A-Z][A-Z_0-9]+)}~'; /** * @var array diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 665b7a81ab..a7c49927f1 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -236,6 +236,15 @@ class phpbb_template_template_test extends phpbb_test_case "first\n0\n0\n2\nx\nset\n1\n1\n2\ny\nset\nlast", ),*/ array( + // Just like a regular loop but the name begins + // with an underscore + 'loop_underscore.html', + array(), + array(), + array(), + "noloop\nnoloop", + ), + array( 'lang.html', array(), array(), diff --git a/tests/template/templates/loop_underscore.html b/tests/template/templates/loop_underscore.html new file mode 100644 index 0000000000..dafce5dea6 --- /dev/null +++ b/tests/template/templates/loop_underscore.html @@ -0,0 +1,21 @@ +<!-- BEGIN _underscore_loop --> +loop +<!-- BEGINELSE --> +noloop +<!-- END loop --> + +<!-- IF ._underscore_loop --> +loop +<!-- ELSE --> +noloop +<!-- ENDIF --> + +<!-- IF ._underscore_loop == 2 --> +loop +<!-- ENDIF --> + +<!-- BEGIN _underscore_loop --> +<!-- BEGIN !block --> +loop#{loop.S_ROW_COUNT}-block#{block.S_ROW_COUNT} +<!-- END !block --> +<!-- END _underscore_loop --> |