Преглед изворни кода

Fix favicon fetching while using proxies (#5421)

* Fix favicon fetching while using proxies

This ensures that if curl_options are defined in config.php, those
settings are respected while fetching favicons.

Fixes FreshRSS#4951

* Change options priority

* Credits keep alphabticorder

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
vrachnis пре 2 година
родитељ
комит
df80913747
2 измењених фајлова са 13 додато и 2 уклоњено
  1. 1 0
      CREDITS.md
  2. 12 2
      lib/favicons.php

+ 1 - 0
CREDITS.md

@@ -80,6 +80,7 @@ People are sorted by name so please keep this order.
 * [hoilc](https://github.com/hoilc): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:hoilc)
 * [ibiruai](https://github.com/ibiruai): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:ibiruai)
 * [id-konstantin-stepanov](https://github.com/id-konstantin-stepanov): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:id-konstantin-stepanov)
+* [Ilias Vrachnis](https://github.com/vrachnis): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:vrachnis)
 * [Jake Mannens](https://github.com/jakem72360): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:jakem72360)
 * [Jamie Slome](https://github.com/JamieSlome): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:JamieSlome), [Web](https://418sec.com/)
 * [Jan Lukas Gernert](https://github.com/jangernert): [contributions](https://github.com/FreshRSS/FreshRSS/pulls?q=is:pr+author:jangernert)

+ 12 - 2
lib/favicons.php

@@ -28,7 +28,7 @@ function isImgMime(string $content): bool {
 function downloadHttp(string &$url, array $curlOptions = []): string {
 	syslog(LOG_INFO, 'FreshRSS Favicon GET ' . $url);
 	$url = checkUrl($url);
-	if (!$url) {
+	if ($url == false) {
 		return '';
 	}
 	/** @var CurlHandle $ch */
@@ -41,9 +41,19 @@ function downloadHttp(string &$url, array $curlOptions = []): string {
 			CURLOPT_FOLLOWLOCATION => true,
 			CURLOPT_ENCODING => '',	//Enable all encodings
 		]);
+
+	FreshRSS_Context::initSystem();
+	$system_conf = FreshRSS_Context::$system_conf;
+	if (isset($system_conf)) {
+		curl_setopt_array($ch, $system_conf->curl_options);
+	}
+
 	curl_setopt_array($ch, $curlOptions);
-	/** @var string $response */
+
 	$response = curl_exec($ch);
+	if (!is_string($response)) {
+		$response = '';
+	}
 	$info = curl_getinfo($ch);
 	curl_close($ch);
 	if (!empty($info['url'])) {