mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
fixed partial output leak when a PHP fatal error occurs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.40.2 (2019-XX-XX)
|
||||
|
||||
* fixed partial output leak when a PHP fatal error occurs
|
||||
* optimized context access on PHP 7.4
|
||||
|
||||
* 1.40.1 (2019-04-29)
|
||||
|
||||
@@ -54,7 +54,7 @@ function twig_var_dump(Environment $env, $context, array $vars = [])
|
||||
return;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
ob_start(function () { return ''; });
|
||||
|
||||
if (!$vars) {
|
||||
$vars = [];
|
||||
|
||||
@@ -104,7 +104,7 @@ class MacroNode extends Node
|
||||
->outdent()
|
||||
->write("]);\n\n")
|
||||
->write("\$blocks = [];\n\n")
|
||||
->write("ob_start();\n")
|
||||
->write("ob_start(function () { return ''; });\n")
|
||||
->write("try {\n")
|
||||
->indent()
|
||||
->subcompile($this->getNode('body'))
|
||||
|
||||
@@ -58,7 +58,7 @@ class SetNode extends Node implements NodeCaptureInterface
|
||||
} else {
|
||||
if ($this->getAttribute('capture')) {
|
||||
$compiler
|
||||
->write("ob_start();\n")
|
||||
->write("ob_start(function () { return ''; });\n")
|
||||
->subcompile($this->getNode('values'))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class SpacelessNode extends Node
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write("ob_start();\n")
|
||||
->write("ob_start(function () { return ''; });\n")
|
||||
->subcompile($this->getNode('body'))
|
||||
->write("echo trim(preg_replace('/>\s+</', '><', ob_get_clean()));\n")
|
||||
;
|
||||
|
||||
+3
-3
@@ -253,7 +253,7 @@ abstract class Template implements \Twig_TemplateInterface
|
||||
*/
|
||||
public function renderParentBlock($name, array $context, array $blocks = [])
|
||||
{
|
||||
ob_start();
|
||||
ob_start(function () { return ''; });
|
||||
$this->displayParentBlock($name, $context, $blocks);
|
||||
|
||||
return ob_get_clean();
|
||||
@@ -274,7 +274,7 @@ abstract class Template implements \Twig_TemplateInterface
|
||||
*/
|
||||
public function renderBlock($name, array $context, array $blocks = [], $useBlocks = true)
|
||||
{
|
||||
ob_start();
|
||||
ob_start(function () { return ''; });
|
||||
$this->displayBlock($name, $context, $blocks, $useBlocks);
|
||||
|
||||
return ob_get_clean();
|
||||
@@ -417,7 +417,7 @@ abstract class Template implements \Twig_TemplateInterface
|
||||
public function render(array $context)
|
||||
{
|
||||
$level = ob_get_level();
|
||||
ob_start();
|
||||
ob_start(function () { return ''; });
|
||||
try {
|
||||
$this->display($context);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -96,7 +96,7 @@ final class TemplateWrapper
|
||||
{
|
||||
$context = $this->env->mergeGlobals($context);
|
||||
$level = ob_get_level();
|
||||
ob_start();
|
||||
ob_start(function () { return ''; });
|
||||
try {
|
||||
$this->template->displayBlock($name, $context);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -59,7 +59,7 @@ public function getfoo(\$__foo__ = null, \$__bar__ = "Foo"$declaration)
|
||||
|
||||
\$blocks = [];
|
||||
|
||||
ob_start();
|
||||
ob_start(function () { return ''; });
|
||||
try {
|
||||
echo "foo";
|
||||
} catch (\Exception \$e) {
|
||||
|
||||
@@ -49,7 +49,7 @@ EOF
|
||||
$node = new SetNode(true, $names, $values, 1);
|
||||
$tests[] = [$node, <<<EOF
|
||||
// line 1
|
||||
ob_start();
|
||||
ob_start(function () { return ''; });
|
||||
echo "foo";
|
||||
\$context["foo"] = ('' === \$tmp = ob_get_clean()) ? '' : new Markup(\$tmp, \$this->env->getCharset());
|
||||
EOF
|
||||
|
||||
@@ -32,7 +32,7 @@ class Twig_Tests_Node_SpacelessTest extends NodeTestCase
|
||||
return [
|
||||
[$node, <<<EOF
|
||||
// line 1
|
||||
ob_start();
|
||||
ob_start(function () { return ''; });
|
||||
echo "<div> <div> foo </div> </div>";
|
||||
echo trim(preg_replace('/>\s+</', '><', ob_get_clean()));
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user