From 85b3c880ef1ba48091acdfe649c35eef6c1c8f15 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 13 Nov 2019 06:43:36 +0000 Subject: [PATCH] Fix: Mentions in the HTML part of the "contentMap" now are links --- src/Content/Text/BBCode.php | 2 +- src/Protocol/ActivityPub/Transmitter.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 1dffb05073..167a053975 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1680,7 +1680,7 @@ class BBCode extends BaseObject $text = str_replace(["\r","\n"], ['
', '
'], $text); // Remove all hashtag addresses - if ((!$try_oembed || $simple_html) && !in_array($simple_html, [3, 7, 9])) { + if ($simple_html && !in_array($simple_html, [3, 7, 9])) { $text = preg_replace("/([#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $text); } elseif ($simple_html == 3) { // The ! is converted to @ since Diaspora only understands the @ diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 82ee97c9ed..545ac22c69 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1270,7 +1270,10 @@ class Transmitter $data['content'] = BBCode::convert($body, false, 9); } - $data['contentMap']['text/html'] = BBCode::convert($item['body'], false); + $regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism"; + $richbody = preg_replace_callback($regexp, ['self', 'mentionCallback'], $item['body']); + + $data['contentMap']['text/html'] = BBCode::convert($richbody, false); $data['contentMap']['text/markdown'] = BBCode::toMarkdown($item["body"]); $data['source'] = ['content' => $item['body'], 'mediaType' => "text/bbcode"]; -- 2.39.5