You are here

public static function XBBCodeFilter::filterXss in Extensible BBCode 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/Filter/XBBCodeFilter.php \Drupal\xbbcode\Plugin\Filter\XBBCodeFilter::filterXss()

Escape unsafe markup in text elements and the source of tag elements.

This is a safety feature that allows the BBCode processor to be used on its own (without HTML restrictors) while still maintaining markup safety.

Parameters

\Drupal\xbbcode\Parser\Tree\NodeElementInterface $tree: The parse tree.

2 calls to XBBCodeFilter::filterXss()
TagFormBase::form in src/Form/TagFormBase.php
Gets the actual form array to be built.
XBBCodeFilter::process in src/Plugin/Filter/XBBCodeFilter.php
Performs the filter processing.

File

src/Plugin/Filter/XBBCodeFilter.php, line 319

Class

XBBCodeFilter
Provides a filter that converts BBCode to HTML.

Namespace

Drupal\xbbcode\Plugin\Filter

Code

public static function filterXss(NodeElementInterface $tree) : void {
  foreach ($tree
    ->getDescendants() as $node) {
    if ($node instanceof TextElement) {
      $node
        ->setText(XssEscape::filterAdmin($node
        ->getText()));
    }
    if ($node instanceof TagElementInterface) {
      $node
        ->setSource(XssEscape::filterAdmin($node
        ->getSource()));
    }
  }
}