diff --git a/mod/display.php b/mod/display.php index c9d39b1db0..7a8bca4573 100644 --- a/mod/display.php +++ b/mod/display.php @@ -334,8 +334,8 @@ function display_content(App $a, $update = false, $update_uid = 0) $o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', $item_uid); // Preparing the meta header - $description = trim(HTML::toPlaintext(BBCode::convert($item["body"], false), 0, true)); - $title = trim(HTML::toPlaintext(BBCode::convert($item["title"], false), 0, true)); + $description = trim(BBCode::toPlaintext($item["body"])); + $title = trim(BBCode::toPlaintext($item["title"])); $author_name = $item["author-name"]; $image = DI::baseUrl()->remove($item["author-avatar"]); diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 3ecd306b3f..b1244d0ac3 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -433,6 +433,10 @@ class BBCode */ public static function toPlaintext($text, $keep_urls = true) { + // Remove pictures in advance to avoid unneeded proxy calls + $text = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", ' $2 ', $text); + $text = preg_replace("/\[img.*?\[\/img\]/ism", ' ', $text); + $naked_text = HTML::toPlaintext(self::convert($text, false, 0, true), 0, !$keep_urls); return $naked_text; diff --git a/src/Model/Item.php b/src/Model/Item.php index fb88da8a28..a08b934d85 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1008,9 +1008,6 @@ class Item // Check for hashtags in the body and repair or add hashtag links $item['body'] = self::setHashtags($item['body']); - // Fill the cache field - self::putInCache($item); - if (stristr($item['verb'], Activity::POKE)) { $notify_type = Delivery::POKE; } else { diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index f5d8e48ded..f4892b6c0f 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -744,7 +744,7 @@ class Processor $title = $matches[3]; } - $title = trim(HTML::toPlaintext(BBCode::convert($title, false, BBCode::API, true), 0)); + $title = trim(BBCode::toPlaintext($title)); if (strlen($title) > 20) { $title = substr($title, 0, 20) . '...'; diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 42f470e23f..5738c01d8a 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -1199,7 +1199,7 @@ class Feed // Remove the share element before fetching the first line $title = trim(preg_replace("/\[share.*?\](.*?)\[\/share\]/ism","\n$1\n",$item['body'])); - $title = HTML::toPlaintext(BBCode::convert($title, false), 0, true)."\n"; + $title = BBCode::toPlaintext($title)."\n"; $pos = strpos($title, "\n"); $trailer = ""; if (($pos == 0) || ($pos > 100)) {