function _filter_html

Provides filtering of input into accepted HTML.

Related topics

3 calls to _filter_html()
FilterHtml::process in drupal/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php
Performs the filter processing.
FilterUnitTest::testHtmlFilter in drupal/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
Tests filter settings, defaults, access restrictions and similar.
FilterUnitTest::testNoFollowFilter in drupal/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
Tests the spam deterrent.

File

drupal/core/modules/filter/filter.module, line 1039
Framework for handling the filtering of content.

Code

function _filter_html($text, $filter) {
  $allowed_tags = preg_split('/\\s+|<|>/', $filter->settings['allowed_html'], -1, PREG_SPLIT_NO_EMPTY);
  $text = filter_xss($text, $allowed_tags);
  if ($filter->settings['filter_html_nofollow']) {
    $html_dom = filter_dom_load($text);
    $links = $html_dom
      ->getElementsByTagName('a');
    foreach ($links as $link) {
      $link
        ->setAttribute('rel', 'nofollow');
    }
    $text = filter_dom_serialize($html_dom);
  }
  return trim($text);
}