Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
CheckSecurityNode.php
01 <?php
02
03 /*
04 * This file is part of Twig.
05 *
06 * (c) Fabien Potencier
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Twig\Node;
13
14 use Twig\Compiler;
15
16 /**
17 * @author Fabien Potencier <fabien@symfony.com>
18 */
19 class CheckSecurityNode extends Node
20 {
21 private $usedFilters;
22 private $usedTags;
23 private $usedFunctions;
24
25 public function __construct(array $usedFilters, array $usedTags, array $usedFunctions)
26 {
27 $this->usedFilters = $usedFilters;
28 $this->usedTags = $usedTags;
29 $this->usedFunctions = $usedFunctions;
30
31 parent::__construct();
32 }
33
34 public function compile(Compiler $compiler)
35 {
36 $tags = $filters = $functions = [];
37 foreach (['tags', 'filters', 'functions'] as $type) {
38 foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
39 if ($node instanceof Node) {
40 ${$type}[$name] = $node->getTemplateLine();
41 } else {
42 ${$type}[$node] = null;
43 }
44 }
45 }
46
47 $compiler
48 ->write("\n")
49 ->write("public function checkSecurity()\n")
50 ->write("{\n")
51 ->indent()
52 ->write('static $tags = ')->repr(array_filter($tags))->raw(";\n")
53 ->write('static $filters = ')->repr(array_filter($filters))->raw(";\n")
54 ->write('static $functions = ')->repr(array_filter($functions))->raw(";\n\n")
55 ->write("try {\n")
56 ->indent()
57 ->write("\$this->sandbox->checkSecurity(\n")
58 ->indent()
59 ->write(!$tags ? "[],\n" : "['".implode("', '", array_keys($tags))."'],\n")
60 ->write(!$filters ? "[],\n" : "['".implode("', '", array_keys($filters))."'],\n")
61 ->write(!$functions ? "[],\n" : "['".implode("', '", array_keys($functions))."'],\n")
62 ->write("\$this->source\n")
63 ->outdent()
64 ->write(");\n")
65 ->outdent()
66 ->write("} catch (SecurityError \$e) {\n")
67 ->indent()
68 ->write("\$e->setSourceContext(\$this->source);\n\n")
69 ->write("if (\$e instanceof SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {\n")
70 ->indent()
71 ->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n")
72 ->outdent()
73 ->write("} elseif (\$e instanceof SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {\n")
74 ->indent()
75 ->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n")
76 ->outdent()
77 ->write("} elseif (\$e instanceof SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {\n")
78 ->indent()
79 ->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n")
80 ->outdent()
81 ->write("}\n\n")
82 ->write("throw \$e;\n")
83 ->outdent()
84 ->write("}\n\n")
85 ->outdent()
86 ->write("}\n")
87 ;
88 }
89 }
90
91 class_alias('Twig\Node\CheckSecurityNode', 'Twig_Node_CheckSecurity');
92