_filter_html

Versions
4.6 – 6
_filter_html($text, $format)
7
_filter_html($text, $filter)

HTML filter. Provides filtering of input into accepted HTML.

▾ 1 function calls _filter_html()

filter_filter in modules/filter/filter.module
Implementation of hook_filter(). Contains a basic set of essential filters.

Code

modules/filter/filter.module, line 1087

<?php
function _filter_html($text, $format) {
  if (variable_get("filter_html_$format", FILTER_HTML_STRIP) == FILTER_HTML_STRIP) {
    $allowed_tags = preg_split('/\s+|<|>/', variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>'), -1, PREG_SPLIT_NO_EMPTY);
    $text = filter_xss($text, $allowed_tags);
  }

  if (variable_get("filter_html_$format", FILTER_HTML_STRIP) == FILTER_HTML_ESCAPE) {
    // Escape HTML
    $text = check_plain($text);
  }

  if (variable_get("filter_html_nofollow_$format", FALSE)) {
    $text = preg_replace('/<a([^>]+)>/i', '<a\\1 rel="nofollow">', $text);
  }

  return trim($text);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.