'.$bridgeElement->maintainer.'
'; + $card .= '' . $bridgeElement->maintainer . '
'; $card .= ''; return $card; } - - } class HTMLSanitizer { - var $tagsToRemove; var $keptAttributes; var $onlyKeepText; - public static $DEFAULT_CLEAR_TAGS = ["script", "iframe", "input", "form"]; public static $KEPT_ATTRIBUTES = ["title", "href", "src"]; - public static $ONLY_TEXT = []; - function __construct($tags_to_remove = null, $kept_attributes = null, $only_keep_text = null) { - + public function __construct($tags_to_remove = null, $kept_attributes = null, $only_keep_text = null) { $this->tagsToRemove = $tags_to_remove == null ? HTMLSanitizer::$DEFAULT_CLEAR_TAGS : $tags_to_remove; $this->keptAttributes = $kept_attributes == null ? HTMLSanitizer::$KEPT_ATTRIBUTES : $kept_attributes; $this->onlyKeepText = $only_keep_text == null ? HTMLSanitizer::$ONLY_TEXT : $only_keep_text; - } - function sanitize($textToSanitize) { - + public function sanitize($textToSanitize) { $htmlContent = str_get_html($textToSanitize); foreach($htmlContent->find('*[!b38fd2b1fe7f4747d6b1c1254ccd055e]') as $element) { @@ -185,23 +156,20 @@ class HTMLSanitizer { $element->outertext = ''; } else { foreach($element->getAllAttributes() as $attributeName => $attribute) { - if(!in_array($attributeName, $this->keptAttributes)) $element->removeAttribute($attributeName); + if(!in_array($attributeName, $this->keptAttributes)) + $element->removeAttribute($attributeName); } } } return $htmlContent; - } + public static function defaultImageSrcTo($content, $server) { - foreach($content->find('img') as $image) { - - if(strpos($image->src, "http") == NULL && strpos($image->src, "//") == NULL && strpos($image->src, "data:") == NULL) { - $image->src = $server.$image->src; - } - } + foreach($content->find('img') as $image) { + if(strpos($image->src, "http") == NULL && strpos($image->src, "//") == NULL && strpos($image->src, "data:") == NULL) + $image->src = $server.$image->src; + } return $content; - } - + } } -?>