/** * @return string * @param string * @desc Strip forbidden attributes from a tag */ function removeEvilTags($source) { $allowedTags = '<h1><b><br><br><i><a><ul><li><hr><blockquote><img><span><div><font><p><em><strong><center><div><table><td><tr>'; $source = strip_tags($source, $allowedTags); return removeEvilAttributes($source); //return preg_replace('/<(.*?)>/ie', "'<'.removeEvilAttributes('\\1').'>'", $source); }
/** * @return string * @param string * @desc Strip forbidden attributes from an array of matches for an expression like (<)(.*?)(>) */ function _callbackRemoveEvilAttributes($matches) { return $matches[1] . removeEvilAttributes($matches[2]) . $matches[3]; }