From c3e5c77eb3085c86124b625c137ece8528d4144d Mon Sep 17 00:00:00 2001 From: Peter Liebetrau Date: Tue, 29 Jan 2019 22:34:28 +0100 Subject: [PATCH] BBcode, Tags - changes for #pullrequestreview-197771905 --- src/Model/Item.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index c5b952a660..c08eb861cc 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2441,22 +2441,20 @@ class Item extends BaseObject "#$2", $item["body"]); foreach ($tags as $tag) { - if ((strpos($tag, '#') !== 0) || strpos($tag, '[url=')) { + if ((strpos($tag, '#') !== 0) || strpos($tag, '[url=') || $tag[1] == '#') { continue; } $basetag = str_replace('_',' ',substr($tag,1)); - if($basetag[0] != '#') { - $newtag = '#[url=' . System::baseUrl() . '/search?tag=' . $basetag . ']' . $basetag . '[/url]'; + $newtag = '#[url=' . System::baseUrl() . '/search?tag=' . $basetag . ']' . $basetag . '[/url]'; - $item["body"] = str_replace($tag, $newtag, $item["body"]); + $item["body"] = str_replace($tag, $newtag, $item["body"]); - if (!stristr($item["tag"], "/search?tag=" . $basetag . "]" . $basetag . "[/url]")) { - if (strlen($item["tag"])) { - $item["tag"] = ',' . $item["tag"]; - } - $item["tag"] = $newtag . $item["tag"]; + if (!stristr($item["tag"], "/search?tag=" . $basetag . "]" . $basetag . "[/url]")) { + if (strlen($item["tag"])) { + $item["tag"] = ',' . $item["tag"]; } + $item["tag"] = $newtag . $item["tag"]; } }