summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Brahmer <info@b-brahmer.de>2023-01-11 16:43:27 +0100
committerBenjamin Brahmer <info@b-brahmer.de>2023-01-12 18:27:32 +0100
commit502e4b923e3805e7b2f172255e24a51a52a15c96 (patch)
treebfd33baafd226a94e509794182a26b198067f748
parent41264586eadac4c26c6e2644a2c0b06023c4d6df (diff)
don't process link if it's null
don't process body of feed if it's null Co-authored-by: Sean Molenaar <SMillerDev@users.noreply.github.com> Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
-rw-r--r--lib/Db/Feed.php8
-rwxr-xr-xlib/Fetcher/FeedFetcher.php30
2 files changed, 23 insertions, 15 deletions
diff --git a/lib/Db/Feed.php b/lib/Db/Feed.php
index 3c371087b..5821466a5 100644
--- a/lib/Db/Feed.php
+++ b/lib/Db/Feed.php
@@ -326,13 +326,16 @@ class Feed extends Entity implements IAPI, \JsonSerializable
'basicAuthPassword'
]);
+ if (is_null($this->link)) {
+ return $serialized;
+ }
+
$url = parse_url($this->link, PHP_URL_HOST);
// strip leading www. to avoid css class confusion
if (strpos($url, 'www.') === 0) {
$url = substr($url, 4);
}
-
$serialized['cssClass'] = 'custom-' . str_replace('.', '-', $url);
return $serialized;
@@ -488,6 +491,9 @@ class Feed extends Entity implements IAPI, \JsonSerializable
*/
public function setLink(?string $link = null): Feed
{
+ if (is_null($link)) {
+ return $this;
+ }
$link = trim($link);
if (strpos($link, 'http') === 0 && $this->link !== $link) {
$this->link = $link;
diff --git a/lib/Fetcher/FeedFetcher.php b/lib/Fetcher/FeedFetcher.php
index 86e0edd18..c79d40685 100755
--- a/lib/Fetcher/FeedFetcher.php
+++ b/lib/Fetcher/FeedFetcher.php
@@ -301,22 +301,24 @@ class FeedFetcher implements IFeedFetcher
}
// purification is done in the service layer
- $body = mb_convert_encoding(
- $body,
- 'HTML-ENTITIES',
- mb_detect_encoding($body)
- );
- if (strpos($body, 'CDATA') !== false) {
- libxml_use_internal_errors(true);
- $data = simplexml_load_string(
- "<?xml version=\"1.0\"?><item>$body</item>",
- SimpleXMLElement::class,
- LIBXML_NOCDATA
+ if (!is_null($body)) {
+ $body = mb_convert_encoding(
+ $body,
+ 'HTML-ENTITIES',
+ mb_detect_encoding($body)
);
- if ($data !== false && libxml_get_last_error() === false) {
- $body = (string) $data;
+ if (strpos($body, 'CDATA') !== false) {
+ libxml_use_internal_errors(true);
+ $data = simplexml_load_string(
+ "<?xml version=\"1.0\"?><item>$body</item>",
+ SimpleXMLElement::class,
+ LIBXML_NOCDATA
+ );
+ if ($data !== false && libxml_get_last_error() === false) {
+ $body = (string) $data;
+ }
+ libxml_clear_errors();
}
- libxml_clear_errors();
}
$item->setBody($body);