From 7d4854a0a4f5665db599f18c34035786465639f3 Mon Sep 17 00:00:00 2001 From: Inverle Date: Tue, 4 Nov 2025 12:48:31 +0100 Subject: Create separate `Retry-After` files for proxies (#8029) * Create separate `Retry-After` files for proxies Bad proxies are able to send a false `Retry-After` header and affect the availability of feeds (domain-wide) for other users. This PR starts including the address of the proxy if present in filenames for `Retry-After` to mitigate the issue. * Reduce code changes * Sync SimplePie fork https://github.com/FreshRSS/simplepie/pull/62 --------- Co-authored-by: Alexandre Alapetite --- lib/simplepie/simplepie/src/File.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/simplepie') diff --git a/lib/simplepie/simplepie/src/File.php b/lib/simplepie/simplepie/src/File.php index 874438c76..0981ebf96 100644 --- a/lib/simplepie/simplepie/src/File.php +++ b/lib/simplepie/simplepie/src/File.php @@ -145,7 +145,7 @@ class File implements Response $responseHeaders .= "\r\n"; if (curl_errno($fp) === CURLE_WRITE_ERROR || curl_errno($fp) === CURLE_BAD_CONTENT_ENCODING) { $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); // FreshRSS - $this->on_http_response($responseBody === false ? false : $responseHeaders . $responseBody); + $this->on_http_response($responseBody === false ? false : $responseHeaders . $responseBody, $curl_options); $this->error = null; // FreshRSS curl_setopt($fp, CURLOPT_ENCODING, 'none'); $responseHeaders = ''; @@ -156,7 +156,7 @@ class File implements Response if (curl_errno($fp) !== CURLE_OK) { $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); $this->success = false; - $this->on_http_response($responseBody === false ? false : $responseHeaders . $responseBody); + $this->on_http_response($responseBody === false ? false : $responseHeaders . $responseBody, $curl_options); } else { // For PHPStan: `curl_exec` returns `false` only on error so the `is_string` check will always pass. \assert(is_string($responseBody)); @@ -164,7 +164,7 @@ class File implements Response // TODO: Replace with `CURLOPT_SUPPRESS_CONNECT_HEADERS` once PHP 7.2 support is dropped. $responseHeaders = \SimplePie\HTTP\Parser::prepareHeaders($responseHeaders); } - $this->on_http_response($responseHeaders . $responseBody); + $this->on_http_response($responseHeaders . $responseBody, $curl_options); if (\PHP_VERSION_ID < 80000) { curl_close($fp); } @@ -332,8 +332,9 @@ class File implements Response * Triggered just after an HTTP response is received. * @param string|false $response The raw HTTP response headers and body, or false in case of failure (as returned by curl_exec()). * FreshRSS. + * @param array $curl_options */ - protected function on_http_response($response): void + protected function on_http_response($response, array $curl_options = []): void { } -- cgit v1.2.3