Merge pull request #11545 from annando/url-tag

Don't parse tags in links
This commit is contained in:
Hypolite Petovan 2022-05-21 08:44:49 -04:00 committed by GitHub
commit c4ec80e839
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1952,17 +1952,20 @@ class BBCode
* - #[url=<anything>]<term>[/url] * - #[url=<anything>]<term>[/url]
* - [url=<anything>]#<term>[/url] * - [url=<anything>]#<term>[/url]
*/ */
$text = preg_replace_callback("/(?:#\[url\=[^\[\]]*\]|\[url\=[^\[\]]*\]#)(.*?)\[\/url\]/ism", function($matches) use ($simple_html) { self::performWithEscapedTags($text, ['url', 'share'], function ($text) use ($simple_html) {
if ($simple_html == self::ACTIVITYPUB) { $text = preg_replace_callback("/(?:#\[url\=[^\[\]]*\]|\[url\=[^\[\]]*\]#)(.*?)\[\/url\]/ism", function($matches) use ($simple_html) {
return '<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1]) if ($simple_html == self::ACTIVITYPUB) {
. '" data-tag="' . XML::escape($matches[1]) . '" rel="tag ugc">#' return '<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1])
. XML::escape($matches[1]) . '</a>'; . '" data-tag="' . XML::escape($matches[1]) . '" rel="tag ugc">#'
} else { . XML::escape($matches[1]) . '</a>';
return '#<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1]) } else {
. '" class="tag" rel="tag" title="' . XML::escape($matches[1]) . '">' return '#<a href="' . DI::baseUrl() . '/search?tag=' . rawurlencode($matches[1])
. XML::escape($matches[1]) . '</a>'; . '" class="tag" rel="tag" title="' . XML::escape($matches[1]) . '">'
} . 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