Don't parse tags in links

This commit is contained in:
Michael 2022-05-21 11:46:38 +00:00
parent ed350e472f
commit 54d7a435a3

View file

@ -1952,6 +1952,7 @@ class BBCode
* - #[url=<anything>]<term>[/url] * - #[url=<anything>]<term>[/url]
* - [url=<anything>]#<term>[/url] * - [url=<anything>]#<term>[/url]
*/ */
self::performWithEscapedTags($text, ['url'], function ($text) use ($simple_html) {
$text = preg_replace_callback("/(?:#\[url\=[^\[\]]*\]|\[url\=[^\[\]]*\]#)(.*?)\[\/url\]/ism", function($matches) use ($simple_html) { $text = preg_replace_callback("/(?:#\[url\=[^\[\]]*\]|\[url\=[^\[\]]*\]#)(.*?)\[\/url\]/ism", function($matches) use ($simple_html) {
if ($simple_html == self::ACTIVITYPUB) { if ($simple_html == self::ACTIVITYPUB) {
return '<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1]) return '<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1])
@ -1963,6 +1964,8 @@ class BBCode
. XML::escape($matches[1]) . '</a>'; . XML::escape($matches[1]) . '</a>';
} }
}, $text); }, $text);
return $text;
});
// We need no target="_blank" rel="noopener noreferrer" for local links // We need no target="_blank" rel="noopener noreferrer" for local links
// convert links start with DI::baseUrl() as local link without the target="_blank" rel="noopener noreferrer" attribute // convert links start with DI::baseUrl() as local link without the target="_blank" rel="noopener noreferrer" attribute