]> git.mxchange.org Git - friendica.git/commitdiff
Less greedy when replacing attachment elements
authorMichael <heluecht@pirati.ca>
Thu, 29 Apr 2021 04:14:44 +0000 (04:14 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 29 Apr 2021 04:14:44 +0000 (04:14 +0000)
src/Content/Text/BBCode.php
src/Model/Item.php

index 6da5b490586c8c23854ffa07b26cecca11d4e62d..44ef6e7f1b39341fc535f95f97d451fcd8dfe1ba 100644 (file)
@@ -408,7 +408,7 @@ class BBCode
         */
        public static function removeAttachment($body, $no_link_desc = false)
        {
-               return preg_replace_callback("/\s*\[attachment (.*)\](.*?)\[\/attachment\]\s*/ism",
+               return preg_replace_callback("/\s*\[attachment (.*?)\](.*?)\[\/attachment\]\s*/ism",
                        function ($match) use ($no_link_desc) {
                                $attach_data = self::getAttachmentData($match[0]);
                                if (empty($attach_data['url'])) {
index f387a1a7282aeb722a7f0b462c29106bde5d528e..f1ae16a05b281620df1c435dacc597f19dd6bc1e 100644 (file)
@@ -1706,7 +1706,7 @@ class Item
                                        return ("[bookmark=" . str_replace("#", "&num;", $match[1]) . "]" . str_replace("#", "&num;", $match[2]) . "[/bookmark]");
                                }, $body);
 
-                       $body = preg_replace_callback("/\[attachment (.*)\](.*?)\[\/attachment\]/ism",
+                       $body = preg_replace_callback("/\[attachment (.*?)\](.*?)\[\/attachment\]/ism",
                                function ($match) {
                                        return ("[attachment " . str_replace("#", "&num;", $match[1]) . "]" . $match[2] . "[/attachment]");
                                }, $body);
@@ -2640,7 +2640,7 @@ class Item
                }
 
                $orig_body = $item['body'];
-               $item['body'] = preg_replace("/\s*\[attachment .*\].*?\[\/attachment\]\s*/ism", '', $item['body']);
+               $item['body'] = preg_replace("/\s*\[attachment .*?\].*?\[\/attachment\]\s*/ism", '', $item['body']);
                self::putInCache($item);
                $item['body'] = $orig_body;
                $s = $item["rendered-html"];