1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-01 14:30:32 +02:00

[ticket/11833] Prevent Twig errors from invalid template loops using BEGINELSE

PHPBB3-11833
This commit is contained in:
Nathan Guse
2013-09-09 11:26:40 -05:00
parent 0cb4ceabf4
commit 5166240d62

View File

@@ -161,6 +161,9 @@ class phpbb_template_twig_lexer extends Twig_Lexer
$subset = trim(substr($matches[2], 1, -1)); // Remove parenthesis
$body = $matches[3];
// Replace <!-- BEGINELSE -->
$body = str_replace('<!-- BEGINELSE -->', '{% else %}', $body);
// Is the designer wanting to call another loop in a loop?
// <!-- BEGIN loop -->
// <!-- BEGIN !loop2 -->
@@ -205,9 +208,6 @@ class phpbb_template_twig_lexer extends Twig_Lexer
return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}";
};
// Replace <!-- BEGINELSE --> correctly, only needs to be done once
$code = str_replace('<!-- BEGINELSE -->', '{% else %}', $code);
return preg_replace_callback('#<!-- BEGIN ([!a-zA-Z0-9_]+)(\([0-9,\-]+\))? -->(.+?)<!-- END \1 -->#s', $callback, $code);
}