X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=b460d5f79fdf886364acfe50a0c7ddf99a4580e6;hb=fc0acd7b1f4723b9e45badcaae53e466e1a29b85;hp=bb7053187ec4b612c42a5d048d80e09e21eb074f;hpb=2bd62bfdea6ba720c43683a9b747f9c10d389084;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index bb7053187e..b460d5f79f 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2386,24 +2386,23 @@ class Item extends BaseObject public static function setHashtags(&$item) { + $tags = BBCode::getTags($item["body"]); + + // No hashtags? + if (!count($tags)) { + return false; + } // What happens in [code], stays in [code]! // escape the # and the [ // hint: we will also get in trouble with #tags, when we want markdown in posts -> ### Headline 3 - $item["body"] = preg_replace_callback("/\[code(.*)\](.*?)\[\/code\]/ism", + $item["body"] = preg_replace_callback("/\[code(.*?)\](.*?)\[\/code\]/ism", function ($match) { // we truly ESCape all # and [ to prevent gettin weird tags in [code] blocks $find = ['#', '[']; $replace = [chr(27).'sharp', chr(27).'leftsquarebracket']; - return ("[code" . str_replace($find, $replace, $match[1]) . "]" . $match[2] . "[/code]"); + return ("[code" . $match[1] . "]" . str_replace($find, $replace, $match[2]) . "[/code]"); }, $item["body"]); - - $tags = BBCode::getTags($item["body"]); - - // No hashtags? - if (!count($tags)) { - return false; - } // This sorting is important when there are hashtags that are part of other hashtags // Otherwise there could be problems with hashtags like #test and #test2 @@ -2463,12 +2462,12 @@ class Item extends BaseObject // Remember! What happens in [code], stays in [code] // roleback the # and [ - $item["body"] = preg_replace_callback("/\[code(.*)\](.*?)\[\/code\]/ism", + $item["body"] = preg_replace_callback("/\[code(.*?)\](.*?)\[\/code\]/ism", function ($match) { // we truly unESCape all sharp and leftsquarebracket $find = [chr(27).'sharp', chr(27).'leftsquarebracket']; $replace = ['#', '[']; - return ("[code" . str_replace($find, $replace, $match[1]) . "]" . $match[2] . "[/code]"); + return ("[code" . $match[1] . "]" . str_replace($find, $replace, $match[2]) . "[/code]"); }, $item["body"]); }