ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_Extension_Sandbox Class Reference

More...

+ Inheritance diagram for Twig_Extension_Sandbox:
+ Collaboration diagram for Twig_Extension_Sandbox:

Public Member Functions

 __construct (Twig_Sandbox_SecurityPolicyInterface $policy, $sandboxed=false)
 
 getTokenParsers ()
 Returns the token parser instances to add to the existing list. More...
 
 getNodeVisitors ()
 Returns the node visitor instances to add to the existing list. More...
 
 enableSandbox ()
 
 disableSandbox ()
 
 isSandboxed ()
 
 isSandboxedGlobally ()
 
 setSecurityPolicy (Twig_Sandbox_SecurityPolicyInterface $policy)
 
 getSecurityPolicy ()
 
 checkSecurity ($tags, $filters, $functions)
 
 checkMethodAllowed ($obj, $method)
 
 checkPropertyAllowed ($obj, $method)
 
 ensureToStringAllowed ($obj)
 
 getName ()
 Returns the name of the extension. More...
 
- Public Member Functions inherited from Twig_Extension
 initRuntime (Twig_Environment $environment)
 
 getTokenParsers ()
 Returns the token parser instances to add to the existing list. More...
 
 getNodeVisitors ()
 Returns the node visitor instances to add to the existing list. More...
 
 getFilters ()
 Returns a list of filters to add to the existing list. More...
 
 getTests ()
 Returns a list of tests to add to the existing list. More...
 
 getFunctions ()
 Returns a list of functions to add to the existing list. More...
 
 getOperators ()
 Returns a list of operators to add to the existing list. More...
 
 getGlobals ()
 
 getName ()
 

Protected Attributes

 $sandboxedGlobally
 
 $sandboxed
 
 $policy
 

Detailed Description

Definition at line 15 of file Sandbox.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_Extension_Sandbox::__construct ( Twig_Sandbox_SecurityPolicyInterface  $policy,
  $sandboxed = false 
)

Definition at line 21 of file Sandbox.php.

References $policy, and $sandboxed.

22  {
23  $this->policy = $policy;
24  $this->sandboxedGlobally = $sandboxed;
25  }

Member Function Documentation

◆ checkMethodAllowed()

Twig_Extension_Sandbox::checkMethodAllowed (   $obj,
  $method 
)

Definition at line 74 of file Sandbox.php.

References isSandboxed().

75  {
76  if ($this->isSandboxed()) {
77  $this->policy->checkMethodAllowed($obj, $method);
78  }
79  }
+ Here is the call graph for this function:

◆ checkPropertyAllowed()

Twig_Extension_Sandbox::checkPropertyAllowed (   $obj,
  $method 
)

Definition at line 81 of file Sandbox.php.

References isSandboxed().

82  {
83  if ($this->isSandboxed()) {
84  $this->policy->checkPropertyAllowed($obj, $method);
85  }
86  }
+ Here is the call graph for this function:

◆ checkSecurity()

Twig_Extension_Sandbox::checkSecurity (   $tags,
  $filters,
  $functions 
)

Definition at line 67 of file Sandbox.php.

References $tags, and isSandboxed().

68  {
69  if ($this->isSandboxed()) {
70  $this->policy->checkSecurity($tags, $filters, $functions);
71  }
72  }
$tags
Definition: croninfo.php:19
+ Here is the call graph for this function:

◆ disableSandbox()

Twig_Extension_Sandbox::disableSandbox ( )

Definition at line 42 of file Sandbox.php.

43  {
44  $this->sandboxed = false;
45  }

◆ enableSandbox()

Twig_Extension_Sandbox::enableSandbox ( )

Definition at line 37 of file Sandbox.php.

38  {
39  $this->sandboxed = true;
40  }

◆ ensureToStringAllowed()

Twig_Extension_Sandbox::ensureToStringAllowed (   $obj)

Definition at line 88 of file Sandbox.php.

References isSandboxed().

89  {
90  if ($this->isSandboxed() && is_object($obj)) {
91  $this->policy->checkMethodAllowed($obj, '__toString');
92  }
93 
94  return $obj;
95  }
+ Here is the call graph for this function:

◆ getName()

Twig_Extension_Sandbox::getName ( )

Returns the name of the extension.

Returns
string The extension name
Deprecated:
since 1.26 (to be removed in 2.0), not used anymore internally

Implements Twig_ExtensionInterface.

Definition at line 97 of file Sandbox.php.

98  {
99  return 'sandbox';
100  }

◆ getNodeVisitors()

Twig_Extension_Sandbox::getNodeVisitors ( )

Returns the node visitor instances to add to the existing list.

Returns
Twig_NodeVisitorInterface[]

Implements Twig_ExtensionInterface.

Definition at line 32 of file Sandbox.php.

33  {
34  return array(new Twig_NodeVisitor_Sandbox());
35  }
Twig_NodeVisitor_Sandbox implements sandboxing.
Definition: Sandbox.php:19

◆ getSecurityPolicy()

Twig_Extension_Sandbox::getSecurityPolicy ( )

Definition at line 62 of file Sandbox.php.

References $policy.

63  {
64  return $this->policy;
65  }

◆ getTokenParsers()

Twig_Extension_Sandbox::getTokenParsers ( )

Returns the token parser instances to add to the existing list.

Returns
Twig_TokenParserInterface[]

Implements Twig_ExtensionInterface.

Definition at line 27 of file Sandbox.php.

28  {
29  return array(new Twig_TokenParser_Sandbox());
30  }
Marks a section of a template as untrusted code that must be evaluated in the sandbox mode...
Definition: Sandbox.php:25

◆ isSandboxed()

Twig_Extension_Sandbox::isSandboxed ( )

Definition at line 47 of file Sandbox.php.

References $sandboxed.

Referenced by checkMethodAllowed(), checkPropertyAllowed(), checkSecurity(), and ensureToStringAllowed().

48  {
49  return $this->sandboxedGlobally || $this->sandboxed;
50  }
+ Here is the caller graph for this function:

◆ isSandboxedGlobally()

Twig_Extension_Sandbox::isSandboxedGlobally ( )

Definition at line 52 of file Sandbox.php.

References $sandboxedGlobally.

53  {
55  }

◆ setSecurityPolicy()

Twig_Extension_Sandbox::setSecurityPolicy ( Twig_Sandbox_SecurityPolicyInterface  $policy)

Definition at line 57 of file Sandbox.php.

References $policy.

58  {
59  $this->policy = $policy;
60  }

Field Documentation

◆ $policy

Twig_Extension_Sandbox::$policy
protected

Definition at line 19 of file Sandbox.php.

Referenced by __construct(), getSecurityPolicy(), and setSecurityPolicy().

◆ $sandboxed

Twig_Extension_Sandbox::$sandboxed
protected

Definition at line 18 of file Sandbox.php.

Referenced by __construct(), and isSandboxed().

◆ $sandboxedGlobally

Twig_Extension_Sandbox::$sandboxedGlobally
protected

Definition at line 17 of file Sandbox.php.

Referenced by isSandboxedGlobally().


The documentation for this class was generated from the following file: