Merge pull request #1032 from kaystrobach/patch-1

[BUGFIX] allow to load unclean html without exception
This commit is contained in:
troosan 2019-01-02 14:23:56 +01:00 committed by GitHub
commit 8d92409bfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,11 +71,14 @@ class Html
$html = '<body>' . $html . '</body>';
}
//need to remove whitespaces between tags, as loadHTML seems to take those into account
$html = preg_replace('/(\>)\s*(\<)/m', '$1$2', $html);
// Load DOM
libxml_disable_entity_loader(true);
$dom = new \DOMDocument();
$dom->preserveWhiteSpace = $preserveWhiteSpace;
$dom->loadXML($html);
$dom->loadHTML($html, LIBXML_NOWARNING);
self::$xpath = new \DOMXPath($dom);
$node = $dom->getElementsByTagName('body');