diff options
author | Mario <mario@mariovavti.com> | 2020-10-31 09:19:30 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-10-31 09:19:30 +0100 |
commit | 6d83b5b68d176183e147c11e40aaedf8d68e36df (patch) | |
tree | 0b3a4c6765a14cd2a025d60031c7568de90ec669 | |
parent | e24c769f8e0f919a8e182ae072fdedcd16bb60f3 (diff) | |
parent | 0ad7c8f69eb8b0d6087ef9982af90add02770b1c (diff) | |
download | volse-hubzilla-6d83b5b68d176183e147c11e40aaedf8d68e36df.tar.gz volse-hubzilla-6d83b5b68d176183e147c11e40aaedf8d68e36df.tar.bz2 volse-hubzilla-6d83b5b68d176183e147c11e40aaedf8d68e36df.zip |
Merge branch 'cherry-pick-16d450fc' into 'dev'
HTML parsing lib change to standard PHP in scrape_feed() and scrape_vcard()
See merge request hubzilla/core!1882
-rw-r--r-- | include/network.php | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/include/network.php b/include/network.php index 4457f59bc..9d4c00ee8 100644 --- a/include/network.php +++ b/include/network.php @@ -1333,14 +1333,15 @@ function fetch_xrd_links($url) { */ function scrape_feed($url) { - require_once('library/HTML5/Parser.php'); $ret = array(); $level = 0; $x = z_fetch_url($url,false,$level,array('novalidate' => true)); - if(! $x['success']) + if(! $x['success']) { + logger('ERROR fetching URL'); return $ret; + } $headers = $x['header']; $code = $x['return_code']; @@ -1374,17 +1375,16 @@ function scrape_feed($url) { } } + $dom = new DOMDocument(); try { - $dom = HTML5_Parser::parse($s); + $dom->loadHTML( $s); } catch (DOMException $e) { - logger('Parse error: ' . $e); - } - - if(! $dom) { - logger('Failed to parse.'); + logger('Feed parse error: ' . $e); + // logger('Feed parse ERROR: ' . libxml_get_last_error()->message); return $ret; } + $head = $dom->getElementsByTagName('base'); if($head) { foreach($head as $head0) { @@ -1846,15 +1846,15 @@ function probe_api_path($host) { function scrape_vcard($url) { - require_once('library/HTML5/Parser.php'); - $ret = array(); logger('url=' . $url); $x = z_fetch_url($url); - if(! $x['success']) + if(! $x['success']) { + logger('ERROR fetching URL'); return $ret; + } $s = $x['body']; @@ -1871,14 +1871,14 @@ function scrape_vcard($url) { } } + $dom = new DOMDocument(); try { - $dom = HTML5_Parser::parse($s); + $dom->loadHTML( $s); } catch (DOMException $e) { - logger('Parse error: ' . $e); - } - - if(! $dom) + logger('hCard parse error: ' . $e); + // logger('hCard fetch ERROR: ' . libxml_get_last_error()->message); return $ret; + } // Pull out hCard profile elements |