]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
Logging message added
[friendica.git] / include / bbcode.php
index e872d859c53bec8e599715e775ccea8d34d1d8a3..13061958c5f12682deb5bc52f87ea5868f9f5a93 100644 (file)
@@ -268,6 +268,13 @@ function stripcode_br_cb($s) {
        return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]';
 }
 
+function bb_onelinecode_cb($match) {
+       if (strpos($match[1],"<br>")===false){
+               return "<key>".$match[1]."</key>";
+       }
+       return "<code>".$match[1]."</code>";
+}
+
 function tryoembed($match){
        //$url = ((count($match)==2)?$match[1]:$match[2]);
        $url = $match[1];
@@ -1179,7 +1186,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
 
        // If we found an event earlier, strip out all the event code and replace with a reformatted version.
        // Replace the event-start section with the entire formatted event. The other bbcode is stripped.
-       // Summary (e.g. title) is required, earlier revisions only required description (in addition to 
+       // Summary (e.g. title) is required, earlier revisions only required description (in addition to
        // start which is always required). Allow desc with a missing summary for compatibility.
 
        if((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
@@ -1193,6 +1200,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
                $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text);
        }
 
+
+       //replace oneliner <code> with <key>
+       $Text = preg_replace_callback("|(?!<br[^>]*>)<code>([^<]*)</code>(?!<br[^>]*>)|ism", 'bb_onelinecode_cb', $Text);
+
        // Unhide all [noparse] contained bbtags unspacefying them
        // and triming the [noparse] tag.
 
@@ -1207,7 +1218,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
 
        // fix any escaped ampersands that may have been converted into links
        $Text = preg_replace("/\<([^>]*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
-       $Text = preg_replace("/\<([^>]*?)(src|href)=\"(?!http|ftp|mailto|cid)(.*?)\>/ism",'<$1$2="">',$Text);
+       $Text = preg_replace("/\<([^>]*?)(src|href)=\"(?!http|ftp|mailto|gopher|cid)(.*?)\>/ism",'<$1$2="">',$Text);
 
        if($saved_image)
                $Text = bb_replace_images($Text, $saved_image);