mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
do not check sandbox for __toString if method does not exist on object
This commit is contained in:
@@ -93,7 +93,7 @@ class SandboxExtension extends AbstractExtension
|
||||
|
||||
public function ensureToStringAllowed($obj)
|
||||
{
|
||||
if ($this->isSandboxed() && \is_object($obj)) {
|
||||
if ($this->isSandboxed() && \is_object($obj) && method_exists($obj, '__toString')) {
|
||||
$this->policy->checkMethodAllowed($obj, '__toString');
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,9 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Twig\Node\Expression\ArrayExpression;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Expression\GetAttrExpression;
|
||||
use Twig\Node\Expression\NameExpression;
|
||||
use Twig\Node\SandboxedPrintNode;
|
||||
use Twig\Template;
|
||||
use Twig\Test\NodeTestCase;
|
||||
|
||||
class Twig_Tests_Node_SandboxedPrintTest extends NodeTestCase
|
||||
|
||||
Reference in New Issue
Block a user