From 36483a6ecdff70d4d07890e2686e14a46197c1fb Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Fri, 24 Dec 2021 17:35:32 +0000 Subject: [PATCH] [COMPONENT][Link] Ignore html anchors that include mention class --- components/Link/Link.php | 3 ++- plugins/ActivityPub/Util/Model/Note.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/Link/Link.php b/components/Link/Link.php index 8607dce5c3..5fce5f7435 100644 --- a/components/Link/Link.php +++ b/components/Link/Link.php @@ -41,7 +41,8 @@ class Link extends Component { if (Common::config('attachments', 'process_links')) { $matched_urls = []; - preg_match_all($this->getURLRegex(), $content, $matched_urls); + // TODO: This solution to ignore mentions when content is in html is far from ideal + preg_match_all($this->getURLRegex(), preg_replace('##', '', $content), $matched_urls); $matched_urls = array_unique($matched_urls[1]); foreach ($matched_urls as $match) { try { diff --git a/plugins/ActivityPub/Util/Model/Note.php b/plugins/ActivityPub/Util/Model/Note.php index ac4848307e..e99b96b334 100644 --- a/plugins/ActivityPub/Util/Model/Note.php +++ b/plugins/ActivityPub/Util/Model/Note.php @@ -90,7 +90,7 @@ class Note extends Model { $handleInReplyTo = function (AbstractObject|string $type_note): ?int { try { - $parent_note = is_null($type_note->get('inReplyTo')) ? null : ActivityPub::getObjectByUri($type_note->get('inReplyTo'), try_online: true); + $parent_note = \is_null($type_note->get('inReplyTo')) ? null : ActivityPub::getObjectByUri($type_note->get('inReplyTo'), try_online: true); if ($parent_note instanceof \App\Entity\Note) { return $parent_note->getId(); } elseif ($parent_note instanceof Type\AbstractObject && $parent_note->get('type') === 'Note') { @@ -201,7 +201,7 @@ class Note extends Model Conversation::assignLocalConversation($obj, $reply_to); // Need file and note ids for the next step - Event::handle('ProcessNoteContent', [$obj, $obj->getContent(), $obj->getContentType(), $process_note_content_extra_args = []]); + Event::handle('ProcessNoteContent', [$obj, $obj->getRendered(), $obj->getContentType(), $process_note_content_extra_args = []]); if ($processed_attachments !== []) { foreach ($processed_attachments as [$a, $fname]) {