[ 'type' => 'unknown' ] ]; } protected static function _loadHTML($html) { $doc = new DOMDocument(); @$doc->loadHTML($html); if(!$doc) { return [null, null]; } $xpath = new DOMXPath($doc); return [$doc, $xpath]; } protected static function sanitizeHTML($html, $allowImg=true, $baseURL=false) { $allowed = [ 'a', 'abbr', 'b', 'br', 'code', 'del', 'em', 'i', 'q', 'strike', 'strong', 'time', 'blockquote', 'pre', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'li', 'ol', 'span', ]; if($allowImg) $allowed[] = 'img'; $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); $config->set('HTML.AllowedElements', $allowed); if($baseURL) { $config->set('URI.MakeAbsolute', true); $config->set('URI.Base', $baseURL); } $def = $config->getHTMLDefinition(true); // add HTML