summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/Extension/Sandbox.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/lib/Twig/Extension/Sandbox.php')
-rw-r--r--inc/lib/Twig/Extension/Sandbox.php27
1 files changed, 9 insertions, 18 deletions
diff --git a/inc/lib/Twig/Extension/Sandbox.php b/inc/lib/Twig/Extension/Sandbox.php
index bf76c11a..5cb80a71 100644
--- a/inc/lib/Twig/Extension/Sandbox.php
+++ b/inc/lib/Twig/Extension/Sandbox.php
@@ -3,11 +3,15 @@
/*
* This file is part of Twig.
*
- * (c) 2009 Fabien Potencier
+ * (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+
+/**
+ * @final
+ */
class Twig_Extension_Sandbox extends Twig_Extension
{
protected $sandboxedGlobally;
@@ -16,25 +20,15 @@ class Twig_Extension_Sandbox extends Twig_Extension
public function __construct(Twig_Sandbox_SecurityPolicyInterface $policy, $sandboxed = false)
{
- $this->policy = $policy;
+ $this->policy = $policy;
$this->sandboxedGlobally = $sandboxed;
}
- /**
- * Returns the token parser instances to add to the existing list.
- *
- * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
- */
public function getTokenParsers()
{
return array(new Twig_TokenParser_Sandbox());
}
- /**
- * Returns the node visitor instances to add to the existing list.
- *
- * @return array An array of Twig_NodeVisitorInterface instances
- */
public function getNodeVisitors()
{
return array(new Twig_NodeVisitor_Sandbox());
@@ -93,20 +87,17 @@ class Twig_Extension_Sandbox extends Twig_Extension
public function ensureToStringAllowed($obj)
{
- if (is_object($obj)) {
+ if ($this->isSandboxed() && is_object($obj)) {
$this->policy->checkMethodAllowed($obj, '__toString');
}
return $obj;
}
- /**
- * Returns the name of the extension.
- *
- * @return string The extension name
- */
public function getName()
{
return 'sandbox';
}
}
+
+class_alias('Twig_Extension_Sandbox', 'Twig\Extension\SandboxExtension', false);