From 63406883c37c4e01620b445ff1396411110b5fe2 Mon Sep 17 00:00:00 2001 From: Michael Meier Date: Thu, 1 Jan 2026 12:17:38 +0100 Subject: [PATCH 1/2] File: Disable cURL encoding for bad encoding Setting the CURLOPT_ENCODING to 'none' is not officially supported by cURL. Setting it in case of cURL receiving an invalid Content-Encoding header from the server and re-trying would not fix the issue. The current implementation already sets cURL up to send an Accept-Encoding header with all supported encodings a couple of lines above this change. If the fetch still returns a BAD_CONTENT_ENCODING error, the server already ignored the Accept-Encoding headers once. This change, instead of sending 'none' in a re-try, disables cURL's content encoding handling (in practice, handling compression). --- src/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/File.php b/src/File.php index cee2a6e22..0462fafde 100644 --- a/src/File.php +++ b/src/File.php @@ -139,7 +139,7 @@ public function __construct(string $url, int $timeout = 10, int $redirects = 5, $responseHeaders = curl_exec($fp); if (curl_errno($fp) === CURLE_WRITE_ERROR || curl_errno($fp) === CURLE_BAD_CONTENT_ENCODING) { - curl_setopt($fp, CURLOPT_ENCODING, 'none'); + curl_setopt($fp, CURLOPT_ENCODING, null); $responseHeaders = curl_exec($fp); } $this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE); From 6fe31d5d8a61f49fe1db16875b3bff4e0a572f24 Mon Sep 17 00:00:00 2001 From: Michael Meier Date: Thu, 1 Jan 2026 11:19:51 +0100 Subject: [PATCH 2/2] curl: Replace obsolte CURLOPT_ENCODING The CURLOPT_ENCODING option is obsolete since cURL 7.21.6, in favor of CURLOPT_ACCEPT_ENCODING. I've put the updated option name behind a cURL version check, as SimplePie supports older PHP versions which in turn support older cURL versions which don't have the updated option name yet. See: https://curl.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html --- src/File.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/File.php b/src/File.php index cee2a6e22..7dc2e120a 100644 --- a/src/File.php +++ b/src/File.php @@ -121,7 +121,9 @@ public function __construct(string $url, int $timeout = 10, int $redirects = 5, } 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_URL, $url); @@ -139,7 +141,11 @@ public function __construct(string $url, int $timeout = 10, int $redirects = 5, $responseHeaders = curl_exec($fp); if (curl_errno($fp) === CURLE_WRITE_ERROR || curl_errno($fp) === CURLE_BAD_CONTENT_ENCODING) { - curl_setopt($fp, CURLOPT_ENCODING, 'none'); + if (version_compare(\SimplePie\Misc::get_curl_version(), '7.21.6', '>=')) { + curl_setopt($fp, CURLOPT_ACCEPT_ENCODING, 'none'); + } else { + curl_setopt($fp, CURLOPT_ENCODING, 'none'); + } $responseHeaders = curl_exec($fp); } $this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE);