]> git.mxchange.org Git - friendica.git/commitdiff
Avoid proxyfying images that are removed or replaced later
authorMichael <heluecht@pirati.ca>
Mon, 5 Jul 2021 07:00:35 +0000 (07:00 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 5 Jul 2021 07:00:35 +0000 (07:00 +0000)
mod/display.php
src/Content/Text/BBCode.php
src/Model/Item.php
src/Protocol/ActivityPub/Processor.php
src/Protocol/Feed.php

index c9d39b1db08051549ab92cbd3b9f8d153fa94545..7a8bca45731107d88fc11a8eec391a859063de3f 100644 (file)
@@ -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"]);
index 3ecd306b3fbeee8c64877e11cba67661a3feb671..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;
index fb88da8a28a37ffd1ccc59977b327ac623851e20..a08b934d85f87acb90acca3fc03dd268423bf138 100644 (file)
@@ -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 {
index f5d8e48dedace989d7bf41da35d33066ec1be3c3..f4892b6c0fb3143b2bf14d73235656b9b2a52dff 100644 (file)
@@ -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) . '...';
index 42f470e23f1ba01f2b33bd48c592ccb8658201c7..5738c01d8a18ac4649c501ed2e9dee8260dc963f 100644 (file)
@@ -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)) {