TYPO3  7.6
Escape.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\Core\Parser\Interceptor;
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 {
24  protected $interceptorEnabled = true;
25 
33 
38  protected $objectManager;
39 
49  public function process(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface $node, $interceptorPosition, \TYPO3\CMS\Fluid\Core\Parser\ParsingState $parsingState)
50  {
51  if ($interceptorPosition === \TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER) {
52  if (!$node->getUninitializedViewHelper()->isEscapingInterceptorEnabled()) {
53  $this->interceptorEnabled = false;
54  $this->viewHelperNodesWhichDisableTheInterceptor[] = $node;
55  }
56  } elseif ($interceptorPosition === \TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER) {
57  if (end($this->viewHelperNodesWhichDisableTheInterceptor) === $node) {
58  array_pop($this->viewHelperNodesWhichDisableTheInterceptor);
59  if (count($this->viewHelperNodesWhichDisableTheInterceptor) === 0) {
60  $this->interceptorEnabled = true;
61  }
62  }
63  } elseif ($this->interceptorEnabled && $node instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ObjectAccessorNode) {
64  $escapeViewHelper = $this->objectManager->get(\TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlspecialcharsViewHelper::class);
65  $node = $this->objectManager->get(
66  \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::class,
67  $escapeViewHelper,
68  array('value' => $node)
69  );
70  }
71  return $node;
72  }
73 
79  public function getInterceptionPoints()
80  {
81  return array(
85  );
86  }
87 }