You are here

function _filter_html in Drupal 6

Same name and namespace in other branches
  1. 4 modules/filter.module \_filter_html()
  2. 5 modules/filter/filter.module \_filter_html()
  3. 7 modules/filter/filter.module \_filter_html()

HTML filter. Provides filtering of input into accepted HTML.

Related topics

1 call to _filter_html()
filter_filter in modules/filter/filter.module
Implementation of hook_filter().

File

modules/filter/filter.module, line 710
Framework for handling filtering of content.

Code

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);
}