]> git.mxchange.org Git - friendica.git/commitdiff
BBCode - added preg_replacers for local [url] without target="_blank"
authorpeter <peter@jean-luc-picard>
Fri, 25 Jan 2019 00:15:43 +0000 (01:15 +0100)
committerpeter <peter@jean-luc-picard>
Fri, 25 Jan 2019 00:15:43 +0000 (01:15 +0100)
src/Content/Text/BBCode.php

index 78f252b92477bb84366a33dad79b294076f7a9a8..f2254606451a101db6d5c1c919e4c810ddf64129 100644 (file)
@@ -1361,7 +1361,16 @@ class BBCode extends BaseObject
                                . '</a>';
                }, $text);
 
-               $text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="_blank">$1</a>', $text);
+               // We need no target="_blank" for local links
+               // convert links start with System::baseUrl() as local link
+               $escapedBaseUrl = str_replace('://', '\:\/\/', System::baseUrl());
+               $text = preg_replace("/\[url\]($escapedBaseUrl)([$URLSearchString]*)\[\/url\]/ism", '<a href="$1$2">$1$2</a>', $text);
+               $text = preg_replace("/\[url\=($escapedBaseUrl)([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1$2">$3</a>', $text);             
+               // convert links that start with / as local link
+               $text = preg_replace("/\[url\](\/[$URLSearchString]*)\[\/url\]/ism", '<a href="'.System::baseUrl().'$1">$1</a>', $text);
+               $text = preg_replace("/\[url\=(\/[$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="'.System::baseUrl().'$1">$2</a>', $text);         
+
+        $text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="_blank">$1</a>', $text);
                $text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $text);
 
                // Red compatibility, though the link can't be authenticated on Friendica