fix(mastodon.php): add feed helper to improve handling of utf-8 charachters and html entities
This commit is contained in:
parent
788edbcb11
commit
13cb918edb
3 changed files with 13 additions and 7 deletions
|
@ -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 = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue