Jelajahi Sumber

Switch to using CURLOPT_ACCEPT_ENCODING instead of the deprecated CURLOPT_ENCODING (#8376)

* Replace deprecated CURLOPT_ENCODING

The CURLOPT_ENCODING setting has been deprecated in favor of
CURLOPT_ACCEPT_ENCODING.

Signed-off-by: Michael Meier <mmeier1986@gmail.com>

* Sync with our SimplePie fork PR
https://github.com/FreshRSS/simplepie/pull/67
https://github.com/simplepie/simplepie/pull/960
https://github.com/simplepie/simplepie/pull/962

* Our SimplePie PR merged

---------

Signed-off-by: Michael Meier <mmeier1986@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Michael Meier 2 bulan lalu
induk
melakukan
b07ec816b0
5 mengubah file dengan 12 tambahan dan 6 penghapusan
  1. 1 1
      app/Models/Feed.php
  2. 1 1
      app/Utils/httpUtil.php
  3. 1 1
      cli/health.php
  4. 1 1
      lib/composer.json
  5. 8 2
      lib/simplepie/simplepie/src/File.php

+ 1 - 1
app/Models/Feed.php

@@ -1415,7 +1415,7 @@ class FreshRSS_Feed extends Minz_Model {
 				CURLOPT_USERAGENT => FRESHRSS_USERAGENT,
 				CURLOPT_USERAGENT => FRESHRSS_USERAGENT,
 				CURLOPT_MAXREDIRS => 10,
 				CURLOPT_MAXREDIRS => 10,
 				CURLOPT_FOLLOWLOCATION => true,
 				CURLOPT_FOLLOWLOCATION => true,
-				CURLOPT_ENCODING => '',	//Enable all encodings
+				CURLOPT_ACCEPT_ENCODING => '',	//Enable all encodings
 				//CURLOPT_VERBOSE => 1,	// To debug sent HTTP headers
 				//CURLOPT_VERBOSE => 1,	// To debug sent HTTP headers
 			]);
 			]);
 			$response = curl_exec($ch);
 			$response = curl_exec($ch);

+ 1 - 1
app/Utils/httpUtil.php

@@ -339,7 +339,7 @@ final class FreshRSS_http_Util {
 			CURLOPT_MAXREDIRS => 4,
 			CURLOPT_MAXREDIRS => 4,
 			CURLOPT_RETURNTRANSFER => true,
 			CURLOPT_RETURNTRANSFER => true,
 			CURLOPT_FOLLOWLOCATION => true,
 			CURLOPT_FOLLOWLOCATION => true,
-			CURLOPT_ENCODING => '',	//Enable all encodings
+			CURLOPT_ACCEPT_ENCODING => '',	//Enable all encodings
 			//CURLOPT_VERBOSE => 1,	// To debug sent HTTP headers
 			//CURLOPT_VERBOSE => 1,	// To debug sent HTTP headers
 		]);
 		]);
 
 

+ 1 - 1
cli/health.php

@@ -17,7 +17,7 @@ if ($ch === false) {
 curl_setopt_array($ch, [
 curl_setopt_array($ch, [
 	CURLOPT_CONNECTTIMEOUT => is_numeric($options['connect_timeout'] ?? null) ? (int)$options['connect_timeout'] : 3,
 	CURLOPT_CONNECTTIMEOUT => is_numeric($options['connect_timeout'] ?? null) ? (int)$options['connect_timeout'] : 3,
 	CURLOPT_TIMEOUT => is_numeric($options['timeout'] ?? null) ? (int)$options['timeout'] : 5,
 	CURLOPT_TIMEOUT => is_numeric($options['timeout'] ?? null) ? (int)$options['timeout'] : 5,
-	CURLOPT_ENCODING => '',	//Enable all encodings
+	CURLOPT_ACCEPT_ENCODING => '',	//Enable all encodings
 	CURLOPT_HTTPHEADER => [
 	CURLOPT_HTTPHEADER => [
 		'Connection: close',
 		'Connection: close',
 	],
 	],

+ 1 - 1
lib/composer.json

@@ -14,7 +14,7 @@
 		"marienfressinaud/lib_opml": "0.5.1",
 		"marienfressinaud/lib_opml": "0.5.1",
 		"phpgt/cssxpath": "v1.4.0",
 		"phpgt/cssxpath": "v1.4.0",
 		"phpmailer/phpmailer": "7.0.1",
 		"phpmailer/phpmailer": "7.0.1",
-		"simplepie/simplepie": "dev-freshrss#e7b26b4f01d377dc8174d5d4aee961604534d065"
+		"simplepie/simplepie": "dev-freshrss#02d08ffe43b7e93239f90f7d700475891cefcef8"
 	},
 	},
 	"config": {
 	"config": {
 		"sort-packages": true,
 		"sort-packages": true,

+ 8 - 2
lib/simplepie/simplepie/src/File.php

@@ -121,7 +121,9 @@ class File implements Response
                     }
                     }
                     unset($curl_options[CURLOPT_HTTPHEADER]);
                     unset($curl_options[CURLOPT_HTTPHEADER]);
                 }
                 }
-                if (version_compare(\SimplePie\Misc::get_curl_version(), '7.10.5', '>=')) {
+                if (version_compare(\SimplePie\Misc::get_curl_version(), '7.21.6', '>=')) {
+                    curl_setopt($fp, CURLOPT_ACCEPT_ENCODING, '');
+                } elseif (version_compare(\SimplePie\Misc::get_curl_version(), '7.10.5', '>=')) {
                     curl_setopt($fp, CURLOPT_ENCODING, '');
                     curl_setopt($fp, CURLOPT_ENCODING, '');
                 }
                 }
                 curl_setopt($fp, CURLOPT_URL, $url);
                 curl_setopt($fp, CURLOPT_URL, $url);
@@ -147,7 +149,11 @@ class File implements Response
                     $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); // FreshRSS
                     $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); // FreshRSS
                     $this->on_http_response($responseBody === false ? false : $responseHeaders . $responseBody, $curl_options);
                     $this->on_http_response($responseBody === false ? false : $responseHeaders . $responseBody, $curl_options);
                     $this->error = null; // FreshRSS
                     $this->error = null; // FreshRSS
-                    curl_setopt($fp, CURLOPT_ENCODING, 'none');
+                    if (version_compare(\SimplePie\Misc::get_curl_version(), '7.21.6', '>=')) {
+                        curl_setopt($fp, CURLOPT_ACCEPT_ENCODING, null);
+                    } else {
+                        curl_setopt($fp, CURLOPT_ENCODING, null);
+                    }
                     $responseHeaders = '';
                     $responseHeaders = '';
                     $responseBody = curl_exec($fp);
                     $responseBody = curl_exec($fp);
                     $responseHeaders .= "\r\n";
                     $responseHeaders .= "\r\n";