[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Configurator/TemplateChecks/ -> DisallowUnsafeCopyOf.php (source)

   1  <?php
   2  
   3  /**
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2022 The s9e authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Configurator\TemplateChecks;
   9  
  10  use DOMElement;
  11  use s9e\TextFormatter\Configurator\Exceptions\UnsafeTemplateException;
  12  use s9e\TextFormatter\Configurator\Items\Tag;
  13  use s9e\TextFormatter\Configurator\TemplateCheck;
  14  
  15  class DisallowUnsafeCopyOf extends TemplateCheck
  16  {
  17      /**
  18      * Check for unsafe <xsl:copy-of/> elements
  19      *
  20      * Any select expression that is not a set of named attributes is considered unsafe
  21      *
  22      * @param  DOMElement $template <xsl:template/> node
  23      * @param  Tag        $tag      Tag this template belongs to
  24      * @return void
  25      */
  26  	public function check(DOMElement $template, Tag $tag)
  27      {
  28          $nodes = $template->getElementsByTagNameNS(self::XMLNS_XSL, 'copy-of');
  29          foreach ($nodes as $node)
  30          {
  31              $expr = $node->getAttribute('select');
  32  
  33              if (!preg_match('#^@[-\\w]*(?:\\s*\\|\\s*@[-\\w]*)*$#D', $expr))
  34              {
  35                  throw new UnsafeTemplateException("Cannot assess the safety of '" . $node->nodeName . "' select expression '" . $expr . "'", $node);
  36              }
  37          }
  38      }
  39  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1