]> git.mxchange.org Git - friendica.git/blobdiff - library/HTML5/Parser.php
Moving the clean up code to a central place.
[friendica.git] / library / HTML5 / Parser.php
index 5f9ca560e594c2732ac4c0157ef8b61d420e14e0..c7faf875ad326304c44f65aa3f64ff63b07924c6 100644 (file)
@@ -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();