fix(mastodon.php): add feed helper to improve handling of utf-8 charachters and html entities

This commit is contained in:
Cory Dransfeldt 2025-06-03 13:36:39 -07:00
parent ac39f029eb
commit c792427c07
No known key found for this signature in database
3 changed files with 11 additions and 5 deletions

View file

@ -85,15 +85,21 @@ class MastodonPostHandler extends ApiHandler
foreach ($rss->channel->item as $item) {
$items[] = [
"title" => (string) $item->title,
"title" => $this->cleanText((string) $item->title),
"link" => (string) $item->link,
"description" => (string) $item->description,
"description" => $this->cleanText((string) $item->description),
];
}
return $items;
}
private function cleanText(string $text): string
{
$decoded = html_entity_decode($text, ENT_QUOTES | ENT_XML1, 'UTF-8');
return mb_convert_encoding($decoded, 'UTF-8', 'UTF-8');
}
private function postToMastodon(string $content): ?string
{
$headers = [