'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'); public function __construct() { parent::__construct(); } function _normalize_tag($matches) { return '<' . strtolower($matches[1]); } function sanitize($data, $type, $base = '') { //Simplified function $data = trim($data); // Normalise tags (string replacement is case sensitive) $data = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $data); // Remappings $data = str_replace('
', '
', $data); $data = str_replace('
', '
', $data); //Workshopshed: > Workshopshed: $data = preg_replace('|()(?).*(.*)()|', '$2', $data); //N.B. Don't strip comments as blogger uses which is the same as WordPress // Comments might also contain section targetting e.g. //Now clean up foreach ($this->strip_htmltags as $tag) { $pcre = "/<($tag)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$tag" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>|(\/)?>)/siU'; while (preg_match($pcre, $data)) { $data = preg_replace_callback($pcre, array(&$this, 'do_strip_htmltags'), $data); } } foreach ($this->strip_attributes as $attrib) { $data = preg_replace('/(<[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . trim($attrib) . '(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>/', '\1\2\3>', $data); } // Replace relative URLs $this->base = $base; foreach ($this->replace_url_attributes as $element => $attributes) { $data = $this->replace_urls($data, $element, $attributes); } // Images are handled as a separate step as we need to download them // Having (possibly) taken stuff out, there may now be whitespace at the beginning/end of the data $data = trim($data); return $data; } function replace_urls($data, $tag, $attributes) { //This seems to do nothing at all!? if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags)) { $elements = SimplePie_Misc::get_element($tag, $data); foreach ($elements as $element) { if (is_array($attributes)) { foreach ($attributes as $attribute) { if (isset($element['attribs'][$attribute]['data'])) { $element['attribs'][$attribute]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data'], $this->base); $new_element = SimplePie_Misc::element_implode($element); $data = str_replace($element['full'], $new_element, $data); $element['full'] = $new_element; } } } elseif (isset($element['attribs'][$attributes]['data'])) { $element['attribs'][$attributes]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data'], $this->base); $data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data); } } } return $data; } //Latest SimplePie checks for this function public function set_registry(SimplePie_Registry $registry) { parent::set_registry($registry); } } ?>