]> git.mxchange.org Git - friendica.git/commitdiff
BBcode, Tags - moved [code] escaping before BBCode::getTags() call
authorPeter Liebetrau <peter.liebetrau@gmail.com>
Tue, 29 Jan 2019 20:54:20 +0000 (21:54 +0100)
committerPeter Liebetrau <peter.liebetrau@gmail.com>
Tue, 29 Jan 2019 20:54:20 +0000 (21:54 +0100)
src/Model/Item.php

index 77ba9e63448d5fa97d4da0366d747c580185557e..c5b952a660d71d8a478fc7892ce9eb2ab1af4db3 100644 (file)
@@ -2387,6 +2387,17 @@ class Item extends BaseObject
        public static function setHashtags(&$item)
        {
 
+               // 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",
+                       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]");
+                       }, $item["body"]);
+               
                $tags = BBCode::getTags($item["body"]);
 
                // No hashtags?
@@ -2400,17 +2411,6 @@ class Item extends BaseObject
 
                $URLSearchString = "^\[\]";
 
-               // 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",
-                       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]");
-                       }, $item["body"]);
-               
                // All hashtags should point to the home server if "local_tags" is activated
                if (Config::get('system', 'local_tags')) {
                        $item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",