Merge pull request #6516 from Ixiter/develop

BBCode - added preg_replaces for local [url] links without target="_blank"
2022.09-rc
Hypolite Petovan 2019-01-26 14:22:34 -05:00 zatwierdzone przez GitHub
commit 2d49b71a4c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -1361,6 +1361,12 @@ class BBCode extends BaseObject
. '</a>';
}, $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", '<a href="$1">$1</a>', $text);
$text = preg_replace("/\[url\=(".$escapedBaseUrl."[$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$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);