X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=d16dcb6a7fcf7417a1b3ad9d168ccf10854c52af;hb=d4240a265b6993e8afe0a6f528db3b0d70b6e3e3;hp=a587d8c38075e5f6da2dfc066801492d8f6f8eaa;hpb=3e58060b308f045613c3b57b62c0fb47890c7bdb;p=friendica.git diff --git a/include/bbcode.php b/include/bbcode.php index a587d8c380..d16dcb6a7f 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -642,8 +642,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal $Text = preg_replace('/\"\;/','"',$Text); // fix any escaped ampersands that may have been converted into links - $Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text); - $Text = preg_replace("/\<(.*?)(src|href)=\"[^hfm](.*?)\>/ism",'<$1$2="">',$Text); + $Text = preg_replace("/\<([^>]*?)(src|href)=(.*?)\&\;(.*?)\>/ism",'<$1$2=$3&$4>',$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 = ''; - @$doc->loadHTML($doctype."".$Text.""); +// $doctype = ''; +// @$doc->loadHTML($doctype."".$Text.""); - $Text = $doc->saveHTML(); - $Text = str_replace(array("", "", $doctype), array("", "", ""), $Text); +// $Text = $doc->saveHTML(); +// $Text = str_replace(array("", "", $doctype), array("", "", ""), $Text); - $Text = str_replace('
','', $Text); +// $Text = str_replace('
','', $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>/is'; + $Text = preg_replace($pattern, '#$2', $Text); + } + call_hooks('bbcode',$Text); $a->save_timestamp($stamp1, "parser");