Created
January 6, 2017 19:54
-
-
Save mantis/ebe832f13df40581591ee13056351b31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1461,18 +1461,26 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, | |
if ($object instanceof Twig_Template) { | |
throw new Twig_Error_Runtime('Accessing Twig_Template attributes is forbidden.'); | |
} | |
+ static $extensionSandbox = null; | |
+ if ($extensionSandbox === null) { | |
+ if ($env->hasExtension('Twig_Extension_Sandbox')) | |
+ $extensionSandbox = true; | |
+ else | |
+ $extensionSandbox = false; | |
+ } | |
+ | |
// object property | |
if (Twig_Template::METHOD_CALL !== $type) { | |
if (isset($object->$item) || array_key_exists((string) $item, $object)) { | |
if ($isDefinedTest) { | |
return true; | |
} | |
- if ($env->hasExtension('Twig_Extension_Sandbox')) { | |
+ if ($extensionSandbox) { | |
$env->getExtension('Twig_Extension_Sandbox')->checkPropertyAllowed($object, $item); | |
} | |
return $object->$item; | |
} | |
@@ -1537,11 +1545,11 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, | |
if ($isDefinedTest) { | |
return true; | |
} | |
- if ($env->hasExtension('Twig_Extension_Sandbox')) { | |
+ if ($extensionSandbox) { | |
$env->getExtension('Twig_Extension_Sandbox')->checkMethodAllowed($object, $method); | |
} | |
// Some objects throw exceptions when they have __call, and the method we try | |
// to call is not supported. If ignoreStrictCheck is true, we should return null. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment