You are here

public function HtmlTitleFilter::getAllowHtmlTags in HTML Title 8

Get allow html tags array.

1 call to HtmlTitleFilter::getAllowHtmlTags()
HtmlTitleFilter::filterXss in src/HtmlTitleFilter.php
Helper function to help filter out unwanted XSS opportunities.

File

src/HtmlTitleFilter.php, line 89

Class

HtmlTitleFilter
Drupal\html_title\HtmlTitleFilter.

Namespace

Drupal\html_title

Code

public function getAllowHtmlTags() {
  $tags = [];
  $html = str_replace('>', ' />', $this->configFactory
    ->get('html_title.settings')
    ->get('allow_html_tags'));
  $body_child_nodes = Html::load($html)
    ->getElementsByTagName('body')
    ->item(0)->childNodes;
  foreach ($body_child_nodes as $node) {
    if ($node->nodeType === XML_ELEMENT_NODE) {
      $tags[] = $node->tagName;
    }
  }
  return $tags;
}