From 84b38beb9ae58a6d080789517b600e28afb3f2bf Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Sep 2023 22:05:53 +0000 Subject: [PATCH] Improved link removal --- src/Content/Text/BBCode.php | 1 + src/Model/Post/Engagement.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index a981f97d28..5779ab3a2c 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1113,6 +1113,7 @@ class BBCode public static function removeLinks(string $bbcode): string { DI::profiler()->startRecording('rendering'); + $bbcode = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", ' ', $bbcode); $bbcode = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", ' $1 ', $bbcode); $bbcode = preg_replace("/\[img.*?\[\/img\]/ism", ' ', $bbcode); diff --git a/src/Model/Post/Engagement.php b/src/Model/Post/Engagement.php index 4c6f6e0e55..ca6ef8d9fc 100644 --- a/src/Model/Post/Engagement.php +++ b/src/Model/Post/Engagement.php @@ -35,6 +35,7 @@ use Friendica\Model\Verb; use Friendica\Protocol\Activity; use Friendica\Protocol\Relay; use Friendica\Util\DateTimeFormat; +use Friendica\Util\Strings; // Channel @@ -161,6 +162,7 @@ class Engagement $body = Post\Media::addAttachmentsToBody($item['uri-id'], $body, [Post\Media::IMAGE]); $text = BBCode::toPlaintext($body, false); + $text = preg_replace(Strings::autoLinkRegEx(), '', $text); do { $oldtext = $text; -- 2.39.5