aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_rss.php
diff options
context:
space:
mode:
authorGravatar Inverle <inverle@proton.me> 2025-08-30 15:13:10 +0200
committerGravatar GitHub <noreply@github.com> 2025-08-30 15:13:10 +0200
commit43248b461d4f7b74fe0ab761259ef29e4b0636c6 (patch)
tree212a9717343a32dd1c6abc24588ce8dae8639584 /lib/lib_rss.php
parent5cb49094b83582093c2cb06eeb7d2fbd4bcba080 (diff)
Fix curl response parsing (#7866)
* Fix curl response parsing * Specify redirect count with `\SimplePie\HTTP\Parser::prepareHeaders()` instead Simply notify SimplePie of the redirect count before parsing * Better error check * Simplify
Diffstat (limited to 'lib/lib_rss.php')
-rw-r--r--lib/lib_rss.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index c0fe17708..27020960e 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -643,13 +643,16 @@ function httpGet(string $url, string $cachePath, string $type = 'html', array $a
$c_redirect_count = curl_getinfo($ch, CURLINFO_REDIRECT_COUNT);
$c_error = curl_error($ch);
- $parser = new \SimplePie\HTTP\Parser(is_string($response) ? $response : '');
- if ($parser->parse()) {
- $headers = $parser->headers;
- $body = $parser->body;
- } else {
- $headers = [];
- $body = false;
+ $body = false;
+ $headers = [];
+ if ($response !== false) {
+ assert($c_redirect_count >= 0);
+ $response = \SimplePie\HTTP\Parser::prepareHeaders(is_string($response) ? $response : '', $c_redirect_count + 1);
+ $parser = new \SimplePie\HTTP\Parser($response);
+ if ($parser->parse()) {
+ $headers = $parser->headers;
+ $body = $parser->body;
+ }
}
$fail = $c_status != 200 || $c_error != '' || $body === false;