BBCode - optimized preg searchstring

This commit is contained in:
Peter Liebetrau 2019-01-25 17:25:42 +01:00
parent 71e58a0f42
commit 54bec2bc8e

View File

@ -1364,8 +1364,8 @@ class BBCode extends BaseObject
// We need no target="_blank" for local links // We need no target="_blank" for local links
// convert links start with System::baseUrl() as local link without the target="_blank" attribute // convert links start with System::baseUrl() as local link without the target="_blank" attribute
$escapedBaseUrl = preg_quote(System::baseUrl(), '/'); $escapedBaseUrl = preg_quote(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">$1</a>', $text);
$text = preg_replace("/\[url\=($escapedBaseUrl)([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1$2">$3</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">$1</a>', $text);
$text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $text); $text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $text);