From 958cbffb9139725221f47d51b3c92762b490bb72 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Mon, 20 Sep 2021 17:02:35 +0100 Subject: [PATCH] [Posting] Add text/html content type, must actually treat it --- components/Posting/Posting.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/components/Posting/Posting.php b/components/Posting/Posting.php index ac8a54a830..6bd6902426 100644 --- a/components/Posting/Posting.php +++ b/components/Posting/Posting.php @@ -28,6 +28,7 @@ use App\Core\Form; use App\Core\GSFile; use function App\Core\I18n\_m; use App\Core\Modules\Component; +use App\Core\Security; use App\Entity\Actor; use App\Entity\ActorToAttachment; use App\Entity\Attachment; @@ -170,12 +171,18 @@ class Posting extends Component public function onRenderNoteContent(string $content, string $content_type, ?string &$rendered, Actor $author, ?Note $reply_to = null) { - if ($content_type === 'text/plain') { - $content = Formatting::renderPlainText($content); - $rendered = Formatting::linkifyMentions($content, $author, $reply_to); - return Event::stop; + switch ($content_type) { + case 'text/plain': + $rendered = Formatting::renderPlainText($content); + $rendered = Formatting::linkifyMentions($rendered, $author, $reply_to); + return Event::stop; + case 'text/html': + // TODO: It has to linkify and stuff as well + $rendered = Security::sanitize($content); + return Event::stop; + default: + return Event::next; } - return Event::next; } /**