fix(FeedParser): scrape out content from rss content:encoded (#4178)

* fix(FeedParser): parse content module from rss2

* refactor
This commit is contained in:
Dag 2024-07-31 19:04:07 +02:00 committed by GitHub
parent e55e9b8fac
commit b8a9f34527
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 39 additions and 20 deletions

View file

@ -186,21 +186,26 @@ class FeedItem
}
/**
* @param string|object $content The item content as text or simple_html_dom object.
* @param string|array|\simple_html_dom|\simple_html_dom_node $content The item content
*/
public function setContent($content)
{
$this->content = null;
if (
$content instanceof simple_html_dom
|| $content instanceof simple_html_dom_node
) {
$content = (string) $content;
} elseif (is_array($content)) {
// Assuming this is the rss2.0 content module
$content = $content['encoded'] ?? '';
}
if (is_string($content)) {
$this->content = $content;
} else {
Debug::log(sprintf('Feed content must be a string but got %s', gettype($content)));
Debug::log(sprintf('Unable to convert feed content to string: %s', gettype($content)));
}
}