Improved link removal

This commit is contained in:
Michael 2023-09-25 22:05:53 +00:00
parent b2758f2cdd
commit 84b38beb9a
2 changed files with 3 additions and 0 deletions

View file

@ -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);

View file

@ -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;