]> git.mxchange.org Git - friendica.git/commitdiff
Check Content\Item::replaceTag return for false return value before using it
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 31 May 2021 05:35:49 +0000 (01:35 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 31 May 2021 12:29:50 +0000 (08:29 -0400)
- Address https://github.com/friendica/friendica/issues/10169#issuecomment-835547443
- Remove unused code in Content\Item::replaceTag

mod/item.php
src/Content/Item.php
src/Content/Text/BBCode.php

index 71793f14dc44a6bdc389b6fd1d052d921811a18a..208477b19ae1eac06a5b3957ef6676b24370748d 100644 (file)
@@ -410,21 +410,22 @@ function item_post(App $a) {
                                }
                        }
 
-                       $success = ItemHelper::replaceTag($body, $inform, local_user() ? local_user() : $profile_uid, $tag, $network);
-                       if ($success['replaced']) {
-                               $tagged[] = $tag;
-                       }
-                       // When the forum is private or the forum is addressed with a "!" make the post private
-                       if (!empty($success['contact']['prv']) || ($tag_type == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION])) {
-                               $private_forum = $success['contact']['prv'];
-                               $only_to_forum = ($tag_type == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]);
-                               $private_id = $success['contact']['id'];
-                               $forum_contact = $success['contact'];
-                       } elseif (!empty($success['contact']['forum']) && ($str_contact_allow == '<' . $success['contact']['id'] . '>')) {
-                               $private_forum = false;
-                               $only_to_forum = true;
-                               $private_id = $success['contact']['id'];
-                               $forum_contact = $success['contact'];
+                       if ($success = ItemHelper::replaceTag($body, $inform, local_user() ? local_user() : $profile_uid, $tag, $network)) {
+                               if ($success['replaced']) {
+                                       $tagged[] = $tag;
+                               }
+                               // When the forum is private or the forum is addressed with a "!" make the post private
+                               if (!empty($success['contact']['prv']) || ($tag_type == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION])) {
+                                       $private_forum = $success['contact']['prv'];
+                                       $only_to_forum = ($tag_type == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]);
+                                       $private_id = $success['contact']['id'];
+                                       $forum_contact = $success['contact'];
+                               } elseif (!empty($success['contact']['forum']) && ($str_contact_allow == '<' . $success['contact']['id'] . '>')) {
+                                       $private_forum = false;
+                                       $only_to_forum = true;
+                                       $private_id = $success['contact']['id'];
+                                       $forum_contact = $success['contact'];
+                               }
                        }
                }
 
index f0d08d48e63bfdb568aeb24ac4044cea1c7733e4..56836903b3c6ff91694cf3e2df1b4ef8db4bfdda 100644 (file)
@@ -127,16 +127,6 @@ class Item
                        $tag_type = substr($tag, 0, 1);
                        //is it already replaced?
                        if (strpos($tag, '[url=')) {
-                               // Checking for the alias that is used for OStatus
-                               $pattern = '/[@!]\[url\=(.*?)\](.*?)\[\/url\]/ism';
-                               if (preg_match($pattern, $tag, $matches)) {
-                                       $data = Contact::getByURL($matches[1], false, ['alias', 'nick']);
-
-                                       if ($data['alias'] != '') {
-                                               $newtag = '@[url=' . $data['alias'] . ']' . $data['nick'] . '[/url]';
-                                       }
-                               }
-
                                return $replaced;
                        }
 
index 03ccd889a47ba43e6cbb1fb6008665cb0b0ca4f8..2bb563e74a4944ec20bc976645d9603e39363c57 100644 (file)
@@ -2196,9 +2196,7 @@ class BBCode
                                        }
                                }
 
-                               $success = Item::replaceTag($body, $inform, $profile_uid, $tag, $network);
-
-                               if ($success['replaced']) {
+                               if (($success = Item::replaceTag($body, $inform, $profile_uid, $tag, $network)) && $success['replaced']) {
                                        $tagged[] = $tag;
                                }
                        }