]> git.mxchange.org Git - friendica.git/commitdiff
Don't parse tags in links
authorMichael <heluecht@pirati.ca>
Sat, 21 May 2022 11:46:38 +0000 (11:46 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 21 May 2022 11:46:38 +0000 (11:46 +0000)
src/Content/Text/BBCode.php

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