summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/Extension/Sandbox.php
diff options
context:
space:
mode:
authorAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:22:40 +1000
committerAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:22:40 +1000
commit92561d7f36508b7e0271926e417adf0e2e53916b (patch)
treea8588b4f70af276c5acf58836e33b1f6ff5c61e8 /inc/lib/Twig/Extension/Sandbox.php
parent6f1083e4b51fc9c4c594f6c72cf3d84ef4d0298b (diff)
Initial attempt a switch to composer and PHP-8.1 compatibility
Diffstat (limited to 'inc/lib/Twig/Extension/Sandbox.php')
-rw-r--r--inc/lib/Twig/Extension/Sandbox.php103
1 files changed, 0 insertions, 103 deletions
diff --git a/inc/lib/Twig/Extension/Sandbox.php b/inc/lib/Twig/Extension/Sandbox.php
deleted file mode 100644
index 5cb80a71..00000000
--- a/inc/lib/Twig/Extension/Sandbox.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (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;
- protected $sandboxed;
- protected $policy;
-
- public function __construct(Twig_Sandbox_SecurityPolicyInterface $policy, $sandboxed = false)
- {
- $this->policy = $policy;
- $this->sandboxedGlobally = $sandboxed;
- }
-
- public function getTokenParsers()
- {
- return array(new Twig_TokenParser_Sandbox());
- }
-
- public function getNodeVisitors()
- {
- return array(new Twig_NodeVisitor_Sandbox());
- }
-
- public function enableSandbox()
- {
- $this->sandboxed = true;
- }
-
- public function disableSandbox()
- {
- $this->sandboxed = false;
- }
-
- public function isSandboxed()
- {
- return $this->sandboxedGlobally || $this->sandboxed;
- }
-
- public function isSandboxedGlobally()
- {
- return $this->sandboxedGlobally;
- }
-
- public function setSecurityPolicy(Twig_Sandbox_SecurityPolicyInterface $policy)
- {
- $this->policy = $policy;
- }
-
- public function getSecurityPolicy()
- {
- return $this->policy;
- }
-
- public function checkSecurity($tags, $filters, $functions)
- {
- if ($this->isSandboxed()) {
- $this->policy->checkSecurity($tags, $filters, $functions);
- }
- }
-
- public function checkMethodAllowed($obj, $method)
- {
- if ($this->isSandboxed()) {
- $this->policy->checkMethodAllowed($obj, $method);
- }
- }
-
- public function checkPropertyAllowed($obj, $method)
- {
- if ($this->isSandboxed()) {
- $this->policy->checkPropertyAllowed($obj, $method);
- }
- }
-
- public function ensureToStringAllowed($obj)
- {
- if ($this->isSandboxed() && is_object($obj)) {
- $this->policy->checkMethodAllowed($obj, '__toString');
- }
-
- return $obj;
- }
-
- public function getName()
- {
- return 'sandbox';
- }
-}
-
-class_alias('Twig_Extension_Sandbox', 'Twig\Extension\SandboxExtension', false);