X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FText%2FBBCode.php;h=a8b5ec2025546e7ffa0e694597d2f38524ccd8b1;hb=5e2cbce9b6efce2baaed69b6aad1537a51bdae9d;hp=b77923013bec929532ce4d7b6f9ebc187f36b4d5;hpb=3282ce53894b624893ee2989747a59866ab4b137;p=friendica.git diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index b77923013b..a8b5ec2025 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1150,7 +1150,7 @@ class BBCode extends BaseObject * @return string * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function convert($text, $try_oembed = true, $simple_html = false, $for_plaintext = false) + public static function convert($text, $try_oembed = true, $simple_html = 0, $for_plaintext = false) { $a = self::getApp(); @@ -1178,7 +1178,7 @@ class BBCode extends BaseObject // Extracting multi-line code blocks before the whitespace processing $codeblocks = []; - $text = preg_replace_callback("#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#is", + $text = preg_replace_callback("#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#ism", function ($matches) use (&$codeblocks) { $return = $matches[0]; if (strpos($matches[2], "\n") !== false) { @@ -1293,7 +1293,7 @@ class BBCode extends BaseObject $text); } elseif ($simple_html == 7) { $text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", - '$1$3', + '$1$3', $text); } elseif (!$simple_html) { $text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", @@ -1361,6 +1361,12 @@ class BBCode extends BaseObject . ''; }, $text); + // We need no target="_blank" for local links + // convert links start with System::baseUrl() as local link without the target="_blank" attribute + $escapedBaseUrl = preg_quote(System::baseUrl(), '/'); + $text = preg_replace("/\[url\](".$escapedBaseUrl."[$URLSearchString]*)\[\/url\]/ism", '$1', $text); + $text = preg_replace("/\[url\=(".$escapedBaseUrl."[$URLSearchString]*)\](.*?)\[\/url\]/ism", '$2', $text); + $text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '$1', $text); $text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$2', $text); @@ -1683,7 +1689,7 @@ class BBCode extends BaseObject // Replace non graphical smilies for external posts if ($simple_html) { - $text = Smilies::replace($text, false, true); + $text = Smilies::replace($text); } // Unhide all [noparse] contained bbtags unspacefying them @@ -1737,7 +1743,7 @@ class BBCode extends BaseObject // Clean up the HTML by loading and saving the HTML with the DOM. // Bad structured html can break a whole page. - // For performance reasons do it only with ativated item cache or at export. + // For performance reasons do it only with activated item cache or at export. if (!$try_oembed || (get_itemcachepath() != "")) { $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; @@ -1953,7 +1959,7 @@ class BBCode extends BaseObject $string = preg_replace('/#\[url\=([^\[\]]*)\](.*?)\[\/url\]/ism', '#$2', $string); // ignore anything in a code block - $string = preg_replace('/\[code\](.*?)\[\/code\]/sm', '', $string); + $string = preg_replace('/\[code.*?\].*?\[\/code\]/sm', '', $string); // Force line feeds at bbtags $string = str_replace(['[', ']'], ["\n[", "]\n"], $string);