function filter_markup
Search API
| 7.x misc.inc | filter_markup($str, $type = "basic") |
| 6.x misc.inc | filter_markup($str, $type = "basic") |
| 5.x misc.inc | filter_markup($str, $type = "basic") |
Filter string with possible HTML, allowing only certain tags, and removing dangerous attributes.
$type can be:
- "plain" - No HTML tags are allowed. Safest.
- "basic" - Only certain tags allowed, no attributes. Safest. New lines are converted to HTML break tags.
- "full" - All HTML is allowed through.
36 calls to filter_markup()
- admin.courses.inc in modules/
admin/ admin.courses.inc - admin.degrees.inc in modules/
admin/ admin.degrees.inc - admin.groups.inc in modules/
admin/ admin.groups.inc - admin_edit_course_form_submit in modules/
admin/ admin.courses.inc - admin_edit_degree_form_submit in modules/
admin/ admin.degrees.inc
File
- includes/
misc.inc, line 1196 - This file contains misc functions for FlightPath
Code
function filter_markup($str, $type = "basic") {
if (!$str) {
return $str;
}
if (!is_string($str)) {
return $str;
}
if ($type == 'plain') {
$str = strip_tags($str);
return $str;
}
// If we are here, we're doing something with HTML...
// Fix mismatched HTML (without adding new tags).
$str = repair_html($str);
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);
}
if ($type == "full") {
// Essentially, do nothing. All HTML is allowed through.
}
return $str;
}
