From: Michael Vogel Date: Mon, 8 Dec 2014 21:37:49 +0000 (+0100) Subject: Moving the clean up code to a central place. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=04106ff6f52b03d0d5b009f07a7b6ab11107f0c0;p=friendica.git Moving the clean up code to a central place. --- diff --git a/include/Scrape.php b/include/Scrape.php index ad9e030a39..99784af336 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -263,11 +263,6 @@ function scrape_feed($url) { } try { - // Cleanup invalid HTML - $doc = new DOMDocument(); - @$doc->loadHTML($s); - $s = $doc->saveHTML(); - $dom = HTML5_Parser::parse($s); } catch (DOMException $e) { logger('scrape_feed: parse error: ' . $e); diff --git a/library/HTML5/Parser.php b/library/HTML5/Parser.php index 5f9ca560e5..c7faf875ad 100644 --- a/library/HTML5/Parser.php +++ b/library/HTML5/Parser.php @@ -17,6 +17,12 @@ class HTML5_Parser * @return Parsed HTML as DOMDocument */ static public function parse($text, $builder = null) { + + // Cleanup invalid HTML + $doc = new DOMDocument(); + @$doc->loadHTML($text); + $text = $doc->saveHTML(); + $tokenizer = new HTML5_Tokenizer($text, $builder); $tokenizer->parse(); return $tokenizer->save();