From db90e3bf2527755d4a14186e771d63e8822355b1 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Mon, 5 Jul 2021 20:20:39 +0000
Subject: [PATCH] Remove attachment on plaintext conversion

---
 src/Content/Text/BBCode.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php
index b1244d0ac..8eef48704 100644
--- a/src/Content/Text/BBCode.php
+++ b/src/Content/Text/BBCode.php
@@ -437,6 +437,9 @@ class BBCode
 		$text = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", ' $2 ', $text);
 		$text = preg_replace("/\[img.*?\[\/img\]/ism", ' ', $text);
 
+		// Remove attachment
+		$text = self::removeAttachment($text);
+
 		$naked_text = HTML::toPlaintext(self::convert($text, false, 0, true), 0, !$keep_urls);
 
 		return $naked_text;
@@ -958,7 +961,7 @@ class BBCode
 	public static function fetchShareAttributes($text)
 	{
 		// See Issue https://github.com/friendica/friendica/issues/10454
-		// Hashtags in usernames are expanded to links. This here is a quick fix. 
+		// Hashtags in usernames are expanded to links. This here is a quick fix.
 		$text = preg_replace('/([@!#])\[url\=.*?\](.*?)\[\/url\]/ism', '$1$2', $text);
 
 		$attributes = [];
@@ -2130,8 +2133,8 @@ class BBCode
 	/**
 	 * Expand tags to URLs
 	 *
-	 * @param string $body 
-	 * @return string body with expanded tags 
+	 * @param string $body
+	 * @return string body with expanded tags
 	 */
 	public static function expandTags(string $body)
 	{