From 6f5c689fade5b58a01a3ef47a721e695b6d5893b Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Fri, 30 Apr 2021 12:58:17 +0200 Subject: check if file was actually downloaded Signed-off-by: Benjamin Brahmer --- lib/Fetcher/FeedFetcher.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/Fetcher/FeedFetcher.php b/lib/Fetcher/FeedFetcher.php index 365b86848..f1c6fdb90 100755 --- a/lib/Fetcher/FeedFetcher.php +++ b/lib/Fetcher/FeedFetcher.php @@ -335,25 +335,23 @@ class FeedFetcher implements IFeedFetcher } $favicon_path = join("/", [$this->ITempManager->getTempBaseDir(), basename($favicon)]); - copy( + + $downloaded = copy( $favicon, $favicon_path ); - $is_image = substr(mime_content_type($favicon_path), 0, 5) === "image"; - - $base_url = new Net_URL2($url); - $base_url->setPath(''); + $is_image = $downloaded && substr(mime_content_type($favicon_path), 0, 5) === "image"; // check if file is actually an image if (!$is_image) { - return $this->faviconFactory->get($base_url->getNormalizedURL()); + return $this->faviconFactory->get($url); } list($width, $height, $type, $attr) = getimagesize($favicon_path); // check if image is square else fall back to favicon if ($width !== $height) { - return $this->faviconFactory->get($base_url); + return $this->faviconFactory->get($url); } return $favicon; -- cgit v1.2.3