fckeditor_filter_xss
- Versions
- 6
fckeditor_filter_xss()
AJAX callback - XSS filter
Code
contrib/fckeditor/fckeditor.module, line 110
<?php
function fckeditor_filter_xss() {
$GLOBALS['devel_shutdown'] = FALSE;
if (!isset($_POST['text']) || !is_string($_POST['text']) || !is_array($_POST['filters'])) {
exit;
}
$text = $_POST['text'];
$text = strtr($text, array('<!--' => '__COMMENT__START__', '-->' => '__COMMENT__END__'));
foreach ($_POST['filters'] as $module_delta) {
$module = strtok($module_delta, "/");
$delta = strtok("/");
$format = strtok("/");
if (!module_hook($module, 'filter')) {
continue;
}
//built-in filter module, a special case where we would like to strip XSS and nothing more
if ($module == 'filter' && $delta == 0) {
preg_match_all("|</?([a-z][a-z0-9]*)(?:\b[^>]*)>|i", $text, $matches);
if ($matches[1]) {
$tags = array_unique($matches[1]);
$text = filter_xss($text, $tags);
}
}
else {
$text = module_invoke($module, 'filter', 'process', $delta, $format, $text);
}
}
$text = strtr($text, array('__COMMENT__START__' => '<!--', '__COMMENT__END__' => '-->'));
echo $text;
exit;
}
?>


