Check for errors at HTML parsing

This commit is contained in:
Phyks 2014-07-18 23:13:33 +02:00
parent ce15802830
commit 6774e880ed

View File

@ -47,8 +47,14 @@ function getFavicon($urls) {
$html = new DOMDocument(); $html = new DOMDocument();
$html->strictErrorChecking = false; $html->strictErrorChecking = false;
@$html->loadHTML($content); $success = @$html->loadHTML($content);
if($success === false) {
continue;
}
$xml = simplexml_import_dom($html); $xml = simplexml_import_dom($html);
if($xml === false) {
continue;
}
// Try to fetch the favicon URL from the <head> tag // Try to fetch the favicon URL from the <head> tag
foreach($xml->head->children() as $head_tag) { foreach($xml->head->children() as $head_tag) {