From 57e31fe5a7315507ccda78a1f38f79b1c355b054 Mon Sep 17 00:00:00 2001 From: wn_ Date: Sun, 14 Aug 2022 16:38:58 +0000 Subject: [PATCH 1/2] Handle valid HTTP responses with no response body. --- classes/urlhelper.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/classes/urlhelper.php b/classes/urlhelper.php index bb51f5d06..f8fdd7de9 100644 --- a/classes/urlhelper.php +++ b/classes/urlhelper.php @@ -462,7 +462,11 @@ class UrlHelper { } if (!$contents) { - self::$fetch_last_error = curl_errno($ch) . " " . curl_error($ch); + if (curl_errno($ch) === 0) { + self::$fetch_last_error = 'Successful response, but no content was received.'; + } else { + self::$fetch_last_error = curl_errno($ch) . " " . curl_error($ch); + } curl_close($ch); return false; } @@ -578,6 +582,11 @@ class UrlHelper { return false; } + if (!$data) { + self::$fetch_last_error = 'Successful response, but no content was received.'; + return false; + } + $is_gzipped = RSSUtils::is_gzipped($data); if ($is_gzipped && $data) { From 830a20debf5f26fdd6f4c754a76498a19ead7d0d Mon Sep 17 00:00:00 2001 From: wn_ Date: Sun, 14 Aug 2022 16:52:35 +0000 Subject: [PATCH 2/2] Handle 'file_get_contents()' failure in 'UrlHelper::fetch()'. --- classes/urlhelper.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/classes/urlhelper.php b/classes/urlhelper.php index f8fdd7de9..cdaa6cc87 100644 --- a/classes/urlhelper.php +++ b/classes/urlhelper.php @@ -547,6 +547,11 @@ class UrlHelper { $data = @file_get_contents($url, false, $context); + if ($data === false) { + self::$fetch_last_error = "'file_get_contents' failed."; + return false; + } + foreach ($http_response_header as $header) { if (strstr($header, ": ") !== false) { list ($key, $value) = explode(": ", $header);