Forráskód Böngészése

GReader API: fix incorrect favicon URL (#7792)

* GReader API: fix incorrect favicon URL

* Fix compatibility with custom favicons

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
hilariousperson 8 hónapja
szülő
commit
9faf2c1fa3
2 módosított fájl, 5 hozzáadás és 5 törlés
  1. 2 2
      app/Models/Feed.php
  2. 3 3
      p/api/greader.php

+ 2 - 2
app/Models/Feed.php

@@ -438,7 +438,7 @@ class FreshRSS_Feed extends Minz_Model {
 		@unlink($path . '.ico');
 		@unlink($path . '.txt');
 	}
-	public function favicon(): string {
+	public function favicon(bool $absolute = false): string {
 		$hash = $this->hashFavicon();
 		$url = '/f.php?h=' . $hash;
 		if ($this->customFavicon()
@@ -446,7 +446,7 @@ class FreshRSS_Feed extends Minz_Model {
 			&& !$this->attributeBoolean('customFaviconDisallowDel')) {
 			$url .= '&t=' . @filemtime(DATA_PATH . '/favicons/' . $hash . '.ico');
 		}
-		return Minz_Url::display($url);
+		return Minz_Url::display($url, absolute: $absolute);
 	}
 
 	public function _id(int $value): void {

+ 3 - 3
p/api/greader.php

@@ -332,8 +332,6 @@ final class GReaderAPI {
 			self::internalServerError();
 		}
 		header('Content-Type: application/json; charset=UTF-8');
-		$faviconsUrl = Minz_Url::display('/f.php?', '', true);
-		$faviconsUrl = str_replace('/api/greader.php/reader/api/0/subscription', '', $faviconsUrl);	//Security if base_url is not set properly
 		$subscriptions = [];
 
 		$categoryDAO = FreshRSS_Factory::createCategoryDao();
@@ -352,7 +350,9 @@ final class GReaderAPI {
 					//'firstitemmsec' => 0,
 					'url' => htmlspecialchars_decode($feed->url(), ENT_QUOTES),
 					'htmlUrl' => htmlspecialchars_decode($feed->website(), ENT_QUOTES),
-					'iconUrl' => $faviconsUrl . $feed->hashFavicon(),
+					'iconUrl' => str_replace(
+						'/api/greader.php/reader/api/0/subscription', '',	// Security if base_url is not set properly
+						$feed->favicon(absolute: true)),
 				];
 			}
 		}