]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Text/BBCode.php
Avoid proxyfying images that are removed or replaced later
[friendica.git] / src / Content / Text / BBCode.php
index 6d41cd85cc1a19a9e5c0fe2bd2613884c3c625f4..b1244d0ac3cd44255a15379bdf8b486bc388ad7b 100644 (file)
@@ -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;
@@ -953,6 +957,10 @@ 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. 
+               $text = preg_replace('/([@!#])\[url\=.*?\](.*?)\[\/url\]/ism', '$1$2', $text);
+
                $attributes = [];
                if (!preg_match("/(.*?)\[share(.*?)\](.*)\[\/share\]/ism", $text, $matches)) {
                        return $attributes;
@@ -1008,7 +1016,7 @@ class BBCode
                                if (!empty($author_contact['id'])) {
                                        $attributes['avatar'] = Contact::getAvatarUrlForId($author_contact['id'], ProxyUtils::SIZE_THUMB);
                                } elseif ($attributes['avatar']) {
-                                       $attributes['avatar'] = ProxyUtils::proxifyUrl($attributes['avatar'], false, ProxyUtils::SIZE_THUMB);
+                                       $attributes['avatar'] = ProxyUtils::proxifyUrl($attributes['avatar'], ProxyUtils::SIZE_THUMB);
                                }
 
                                $content = preg_replace(Strings::autoLinkRegEx(), '<a href="$1">$1</a>', $match[3]);