mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11833] Prevent Twig errors from invalid template loops using BEGINELSE
PHPBB3-11833
This commit is contained in:
parent
0cb4ceabf4
commit
5166240d62
1 changed files with 3 additions and 3 deletions
|
@ -161,6 +161,9 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||||
$subset = trim(substr($matches[2], 1, -1)); // Remove parenthesis
|
$subset = trim(substr($matches[2], 1, -1)); // Remove parenthesis
|
||||||
$body = $matches[3];
|
$body = $matches[3];
|
||||||
|
|
||||||
|
// Replace <!-- BEGINELSE -->
|
||||||
|
$body = str_replace('<!-- BEGINELSE -->', '{% else %}', $body);
|
||||||
|
|
||||||
// Is the designer wanting to call another loop in a loop?
|
// Is the designer wanting to call another loop in a loop?
|
||||||
// <!-- BEGIN loop -->
|
// <!-- BEGIN loop -->
|
||||||
// <!-- BEGIN !loop2 -->
|
// <!-- BEGIN !loop2 -->
|
||||||
|
@ -205,9 +208,6 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||||
return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}";
|
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);
|
return preg_replace_callback('#<!-- BEGIN ([!a-zA-Z0-9_]+)(\([0-9,\-]+\))? -->(.+?)<!-- END \1 -->#s', $callback, $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue