A free, self-hostable news aggregator…
Fix enclosures in RSS output (#5540)
Alexandre Alapetite1f05c923762a
diff --git a/app/Models/Entry.php b/app/Models/Entry.phpindex 7e10367fa..77f39f256 100644--- a/app/Models/Entry.php+++ b/app/Models/Entry.php@@ -235,12 +235,12 @@ HTML;/** @return Traversable<array{'url':string,'type'?:string,'medium'?:string,'length'?:int,'title'?:string,'description'?:string,'credit'?:string,'height'?:int,'width'?:int,'thumbnails'?:array<string>}> */public function enclosures(bool $searchBodyImages = false): Traversable {$attributeEnclosures = $this->attributes('enclosures');- if (is_array($attributeEnclosures)) {+ if (is_iterable($attributeEnclosures)) {// FreshRSS 1.20.1+: The enclosures are saved as attributesyield from $attributeEnclosures;}try {- $searchEnclosures = !is_array($attributeEnclosures) && (strpos($this->content, '<p class="enclosure-content') !== false);+ $searchEnclosures = !is_iterable($attributeEnclosures) && (strpos($this->content, '<p class="enclosure-content') !== false);$searchBodyImages &= (stripos($this->content, '<img') !== false);$xpath = null;if ($searchEnclosures || $searchBodyImages) {diff --git a/app/views/index/rss.phtml b/app/views/index/rss.phtmlindex 0b3dc7955..f9c9d9297 100755--- a/app/views/index/rss.phtml+++ b/app/views/index/rss.phtml@@ -48,7 +48,7 @@ foreach ($this->entries as $item) {. '" />', "\n";}$enclosures = $item->enclosures(false);- if (is_array($enclosures)) {+ if (is_iterable($enclosures)) {foreach ($enclosures as $enclosure) {// https://www.rssboard.org/media-rssecho "\t\t\t", '<media:content url="' . $enclosure['url']