function filter_markup

6.x misc.inc filter_markup($str, $type = "basic")
4.x misc.inc filter_markup($str, $type = "basic")
5.x misc.inc filter_markup($str, $type = "basic")

Filter HTML, allowing only certain tags, and removing dangerous attributes.

$type can be:

  • "basic" - Only certain tags allowed, no attributes. Safest. New lines = <br>
  • "full" - All HTML is allowed through.
6 calls to filter_markup()
advise_display_popup_change_track in modules/advise/advise.module
advise_display_popup_change_track_non_dynamic_degree in modules/advise/advise.module
This is the "change track" popup we will display if the degree cannot be combined with anything else (non-dynamic).
announcements_render_announcements in modules/announcements/announcements.module
Return the HTML rendering the announcements we have in the database.
comments_render_comment in modules/comments/comments.module
Display the comment array in a pretty way.
content_render_content in modules/content/content.module
Return the HTML rendering the content we have in the database.

... See full list

File

includes/misc.inc, line 466
This file contains misc functions for FlightPath

Code

function filter_markup($str, $type = "basic") {

  // Use the DOM functions to repair any mismatched HTML.
  $doc = new DOMDocument();
  @$doc->loadHTML($str);
  $str = $doc->saveHTML();


  if ($type == "basic") {

    // To reduce extra newlines, remove any newline which is at the END of an existing <br> tag.
    $str = str_ireplace("<br>\n", "<br />", $str);
    $str = str_ireplace("<br />\n", "<br />", $str);

    $allowed_tags = array('a', 'em', 'strong', 'cite',
      'blockquote', 'code', 'ul', 'ol', 'li',
      'dl', 'dt', 'dd', 'span', 'div',
      'b', 'i', 'u', 'br', 'p', 'table', 'tr',
      'td', 'th', 'tbody',);

    $str = filter_xss($str, $allowed_tags);
    $str = trim($str);
    $str = nl2br($str);

  }


  return $str;

}