A free, self-hostable news aggregator…
Remove dependency to exif extension (#6624)
Alexandre Alapetite783fe19baa0c
diff --git a/lib/favicons.php b/lib/favicons.phpindex a9ebf9f30..3795dc43e 100644--- a/lib/favicons.php+++ b/lib/favicons.php@@ -132,3 +132,16 @@ function download_favicon(string $url, string $dest): bool {return ($favicon != '' && file_put_contents($dest, $favicon) > 0) ||@copy(DEFAULT_FAVICON, $dest);}++function contentType(string $ico): string {+ $ico_content_type = 'image/x-icon';+ if (function_exists('mime_content_type')) {+ $ico_content_type = mime_content_type($ico) ?: $ico_content_type;+ }+ switch ($ico_content_type) {+ case 'image/svg':+ $ico_content_type = 'image/svg+xml';+ break;+ }+ return $ico_content_type;+}diff --git a/p/api/fever.php b/p/api/fever.phpindex ec5af189f..9b9f4bf5d 100644--- a/p/api/fever.php+++ b/p/api/fever.php@@ -351,6 +351,9 @@ final class FeverAPIif (!FreshRSS_Context::hasSystemConf()) {return [];}++ require_once(LIB_PATH . '/favicons.php');+$favicons = [];$salt = FreshRSS_Context::systemConf()->salt;$myFeeds = $this->feedDAO->listFeeds();@@ -365,7 +368,7 @@ final class FeverAPI$favicons[] = ['id' => $feed->id(),- 'data' => image_type_to_mime_type(exif_imagetype($filename) ?: 0) . ';base64,' . base64_encode(file_get_contents($filename) ?: '')+ 'data' => contentType($filename) . ';base64,' . base64_encode(file_get_contents($filename) ?: '')];}diff --git a/p/f.php b/p/f.phpindex 69dc418c9..6514c1045 100644--- a/p/f.php+++ b/p/f.php@@ -49,15 +49,7 @@ if ($ico_mtime == false || $ico_mtime < $txt_mtime || ($ico_mtime < time() - (mt}if (!httpConditional($ico_mtime, mt_rand(14, 21) * 86400, 2)) {- $ico_content_type = 'image/x-icon';- if (function_exists('mime_content_type')) {- $ico_content_type = mime_content_type($ico);- }- switch ($ico_content_type) {- case 'image/svg':- $ico_content_type = 'image/svg+xml';- break;- }+ $ico_content_type = contentType($ico);header('Content-Type: ' . $ico_content_type);header('Content-Disposition: inline; filename="' . $id . '.ico"');readfile($ico);