From 38a7a1da88904faf9fe5ca3c222e5f27920f3300 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 1 Oct 2020 13:20:07 +0300 Subject: [PATCH] hide uninteresting errors in several DOMDocument->loadHTML() invocations --- classes/diskcache.php | 2 +- classes/feeds.php | 2 +- classes/rssutils.php | 6 +++--- plugins/af_redditimgur/init.php | 4 ++-- plugins/cache_starred_images/init.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/classes/diskcache.php b/classes/diskcache.php index 24e45ea8b..6a8aa89c4 100644 --- a/classes/diskcache.php +++ b/classes/diskcache.php @@ -286,7 +286,7 @@ class DiskCache { if (!$res) return ''; $doc = new DOMDocument(); - if ($doc->loadHTML('' . $res)) { + if (@$doc->loadHTML('' . $res)) { $xpath = new DOMXPath($doc); $cache = new DiskCache("images"); diff --git a/classes/feeds.php b/classes/feeds.php index 2d41be2e1..c1b7e8022 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -1930,7 +1930,7 @@ class Feeds extends Handler_Protected { $feedUrls = []; $doc = new DOMDocument(); - if ($doc->loadHTML($content)) { + if (@$doc->loadHTML($content)) { $xpath = new DOMXPath($doc); $entries = $xpath->query('/html/head/link[@rel="alternate" and '. '(contains(@type,"rss") or contains(@type,"atom"))]|/html/head/link[@rel="feed"]'); diff --git a/classes/rssutils.php b/classes/rssutils.php index 2ec24d9be..0e95d4f03 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -1341,9 +1341,9 @@ class RSSUtils { static function cache_media($html, $site_url) { $cache = new DiskCache("images"); - if ($cache->isWritable()) { + if ($html && $cache->isWritable()) { $doc = new DOMDocument(); - if ($doc->loadHTML($html)) { + if (@$doc->loadHTML($html)) { $xpath = new DOMXPath($doc); $entries = $xpath->query('(//img[@src]|//source[@src|@srcset]|//video[@poster|@src])'); @@ -1829,7 +1829,7 @@ class RSSUtils { if ($html = @UrlHelper::fetch($url)) { $doc = new DOMDocument(); - if ($doc->loadHTML($html)) { + if (@$doc->loadHTML($html)) { $xpath = new DOMXPath($doc); $base = $xpath->query('/html/head/base[@href]'); diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 2c213c10b..d3e91f383 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -24,7 +24,7 @@ class Af_RedditImgur extends Plugin { function hook_prefs_tab($args) { if ($args != "prefFeeds") return; - print "
extension ".__('Reddit content settings (af_redditimgur)')."\">"; $enable_readability = $this->host->get($this, "enable_readability"); @@ -111,7 +111,7 @@ class Af_RedditImgur extends Plugin { if ($oembed_result && isset($oembed_result["html"])) { $tmp = new DOMDocument(); - if ($tmp->loadHTML('' . $oembed_result["html"])) { + if (@$tmp->loadHTML('' . $oembed_result["html"])) { $p = $doc->createElement("p"); $p->appendChild($doc->importNode( diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php index 5fe963e32..0911825e7 100755 --- a/plugins/cache_starred_images/init.php +++ b/plugins/cache_starred_images/init.php @@ -190,7 +190,7 @@ class Cache_Starred_Images extends Plugin { $has_images = false; $success = false; - if ($doc->loadHTML('' . $content)) { + if (@$doc->loadHTML('' . $content)) { $xpath = new DOMXPath($doc); $entries = $xpath->query('(//img[@src])|(//video/source[@src])');