mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +00:00
bug #1725 fixed sandbox disabling when using the include function (fabpot)
This PR was merged into the 1.x branch.
Discussion
----------
fixed sandbox disabling when using the include function
closes #1668
Commits
-------
af72894 fixed sandbox disabling when using the include function
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
* 1.18.3 (2015-XX-XX)
|
||||
|
||||
* n/a
|
||||
* fixed sandbox disabling when using the include function
|
||||
|
||||
* 1.18.2 (2015-06-06)
|
||||
|
||||
|
||||
@@ -1427,10 +1427,15 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a
|
||||
}
|
||||
}
|
||||
|
||||
$result = null;
|
||||
try {
|
||||
return $env->resolveTemplate($template)->render($variables);
|
||||
$result = $env->resolveTemplate($template)->render($variables);
|
||||
} catch (Twig_Error_Loader $e) {
|
||||
if (!$ignoreMissing) {
|
||||
if ($isSandboxed && !$alreadySandboxed) {
|
||||
$sandbox->disableSandbox();
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -1438,6 +1443,8 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a
|
||||
if ($isSandboxed && !$alreadySandboxed) {
|
||||
$sandbox->disableSandbox();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
"include" tag sandboxed
|
||||
--TEMPLATE--
|
||||
{{ include("foo.twig", sandboxed = true) }}
|
||||
{{ include("bar.twig") }}
|
||||
--TEMPLATE(foo.twig)--
|
||||
foo
|
||||
--TEMPLATE(bar.twig)--
|
||||
{{ foo|e }}
|
||||
--DATA--
|
||||
return array('foo' => 'bar<br />')
|
||||
--EXPECT--
|
||||
foo
|
||||
|
||||
|
||||
bar<br />
|
||||
@@ -0,0 +1,13 @@
|
||||
--TEST--
|
||||
"include" tag sandboxed
|
||||
--TEMPLATE--
|
||||
{{ include("unknown.twig", sandboxed = true, ignore_missing = true) }}
|
||||
{{ include("bar.twig") }}
|
||||
--TEMPLATE(bar.twig)--
|
||||
{{ foo|e }}
|
||||
--DATA--
|
||||
return array('foo' => 'bar<br />')
|
||||
--EXPECT--
|
||||
|
||||
|
||||
bar<br />
|
||||
Reference in New Issue
Block a user