]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
When converting to HTML, hashtag addresses are now removed (only when the message...
[friendica.git] / include / bbcode.php
index cec13d91977c442fe06a6d22184ffaa8bed43e8b..d16dcb6a7fcf7417a1b3ad9d168ccf10854c52af 100644 (file)
@@ -643,7 +643,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)=\"[^hfm](.*?)\>/ism",'<$1$2="">',$Text);
+       $Text = preg_replace("/\<([^>]*?)(src|href)=\"(?!http|ftp|mailto|cid)(.*?)\>/ism",'<$1$2="">',$Text);
 
        if($saved_image)
                $Text = bb_replace_images($Text, $saved_image);
@@ -652,22 +652,28 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        // Only do it when it has to be done - for performance reasons
        // Update: Now it is done every time - since bad structured html can break a whole page
        //if (!$tryoembed) {
-               $doc = new DOMDocument();
-               $doc->preserveWhiteSpace = false;
+//             $doc = new DOMDocument();
+//             $doc->preserveWhiteSpace = false;
 
-               $Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8");
+//             $Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8");
 
-               $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">';
-               @$doc->loadHTML($doctype."<html><body>".$Text."</body></html>");
+//             $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">';
+//             @$doc->loadHTML($doctype."<html><body>".$Text."</body></html>");
 
-               $Text = $doc->saveHTML();
-               $Text = str_replace(array("<html><body>", "</body></html>", $doctype), array("", "", ""), $Text);
+//             $Text = $doc->saveHTML();
+//             $Text = str_replace(array("<html><body>", "</body></html>", $doctype), array("", "", ""), $Text);
 
-               $Text = str_replace('<br></li>','</li>', $Text);
+//             $Text = str_replace('<br></li>','</li>', $Text);
 
-               $Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
+//             $Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
        //}
 
+       // Remove all hashtag addresses
+       if (!$tryoembed) {
+               $pattern = '/#<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
+               $Text = preg_replace($pattern, '#$2', $Text);
+       }
+
        call_hooks('bbcode',$Text);
 
        $a->save_timestamp($stamp1, "parser");