]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
New option to enable and disable the "share" element
[friendica.git] / include / bbcode.php
index e09b1ed34259ffb02471dda4a9990899c46886ec..f3c4e360d5abc22a2a9c817c7e19c987b6444741 100644 (file)
@@ -3,6 +3,14 @@
 require_once("include/oembed.php");
 require_once('include/event.php');
 
+function bb_cleanstyle($st) {
+  return "<span style=\"".cleancss($st[1]).";\">".$st[2]."</span>";
+}
+
+function bb_cleanclass($st) {
+  return "<span class=\"".cleancss($st[1])."\">".$st[2]."</span>";
+}
+
 function cleancss($input) {
 
        $cleaned = "";
@@ -385,10 +393,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
        $Text = str_replace("[*]", "<li>", $Text);
 
        // Check for style sheet commands
-       $Text = preg_replace("(\[style=(.*?)\](.*?)\[\/style\])ism","<span style=\"$1;\">$2</span>",$Text);
+       $Text = preg_replace_callback("(\[style=(.*?)\](.*?)\[\/style\])ism","bb_cleanstyle",$Text);
 
        // Check for CSS classes
-       $Text = preg_replace("(\[class=(.*?)\](.*?)\[\/class\])ism","<span class=\"$1\">$2</span>",$Text);
+       $Text = preg_replace_callback("(\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanclass",$Text);
 
        // handle nested lists
        $endlessloop = 0;