fix(mastodon.php): add feed helper to improve handling of utf-8 charachters and html entities
This commit is contained in:
parent
ac39f029eb
commit
c792427c07
3 changed files with 11 additions and 5 deletions
|
@ -85,15 +85,21 @@ class MastodonPostHandler extends ApiHandler
|
||||||
|
|
||||||
foreach ($rss->channel->item as $item) {
|
foreach ($rss->channel->item as $item) {
|
||||||
$items[] = [
|
$items[] = [
|
||||||
"title" => (string) $item->title,
|
"title" => $this->cleanText((string) $item->title),
|
||||||
"link" => (string) $item->link,
|
"link" => (string) $item->link,
|
||||||
"description" => (string) $item->description,
|
"description" => $this->cleanText((string) $item->description),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items;
|
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
|
private function postToMastodon(string $content): ?string
|
||||||
{
|
{
|
||||||
$headers = [
|
$headers = [
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "8.2.6",
|
"version": "8.2.7",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "8.2.6",
|
"version": "8.2.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minisearch": "^7.1.2",
|
"minisearch": "^7.1.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "8.2.6",
|
"version": "8.2.7",
|
||||||
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue