mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 20:36:33 +00:00
fixed sandbox security issue
This commit is contained in:
@@ -154,6 +154,11 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $template) {
|
if (null !== $template) {
|
||||||
|
// avoid RCEs when sandbox is enabled
|
||||||
|
if (!$template instanceof Twig_Template) {
|
||||||
|
throw new \LogicException('A block must be a method on a Twig_Template instance.');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$template->$block($context, $blocks);
|
$template->$block($context, $blocks);
|
||||||
} catch (Twig_Error $e) {
|
} catch (Twig_Error $e) {
|
||||||
|
|||||||
@@ -10,6 +10,15 @@
|
|||||||
*/
|
*/
|
||||||
class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @expectedException LogicException
|
||||||
|
*/
|
||||||
|
public function testDisplayBlocksAcceptTemplateOnlyAsBlocks()
|
||||||
|
{
|
||||||
|
$template = $this->getMockForAbstractClass('Twig_Template', array(), '', false);
|
||||||
|
$template->displayBlock('foo', array(), array('foo' => array(new stdClass(), 'foo')));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider getAttributeExceptions
|
* @dataProvider getAttributeExceptions
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user