diff --git a/lib/composer.json b/lib/composer.json index a647f4c87..197ed3a2d 100644 --- a/lib/composer.json +++ b/lib/composer.json @@ -14,7 +14,7 @@ "marienfressinaud/lib_opml": "0.5.1", "phpgt/cssxpath": "v1.3.0", "phpmailer/phpmailer": "6.10.0", - "simplepie/simplepie": "dev-freshrss#f644950102ef4d4ab6e811db6ee9416d7151484a" + "simplepie/simplepie": "dev-freshrss#2f0417355a702c678c237eac5ffc273863301a80" }, "config": { "sort-packages": true, diff --git a/lib/simplepie/simplepie/src/File.php b/lib/simplepie/simplepie/src/File.php index 6f5f37c3c..a6a444f56 100644 --- a/lib/simplepie/simplepie/src/File.php +++ b/lib/simplepie/simplepie/src/File.php @@ -162,7 +162,7 @@ class File implements Response $parser = new \SimplePie\HTTP\Parser($responseHeaders, true); if ($parser->parse()) { $this->set_headers($parser->headers); - $this->body = trim($parser->body); + $this->body = $parser->body; $this->status_code = $parser->status_code; if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && ($locationHeader = $this->get_header_line('location')) !== '' && $this->redirects < $redirects) { $this->redirects++; @@ -246,7 +246,7 @@ class File implements Response $this->error = 'Unable to decode HTTP "gzip" stream'; $this->success = false; } else { - $this->body = trim($decompressed); + $this->body = $decompressed; } break; @@ -288,11 +288,16 @@ class File implements Response $this->error = sprintf('file "%s" is not readable', $url); $this->success = false; } else { - $this->body = trim($filebody); + $this->body = $filebody; $this->status_code = 200; } $this->on_http_response(); } + if ($this->success) { + // (Leading) whitespace may cause XML parsing errors so we trim it, + // but we must not trim \x00 to avoid breaking BOM or multibyte characters + $this->body = trim($this->body, " \n\r\t\v"); + } } /**