]> git.mxchange.org Git - friendica.git/commitdiff
urlencode for tags / fix smiley replacement
authorMichael <heluecht@pirati.ca>
Mon, 12 Feb 2024 04:46:20 +0000 (04:46 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 12 Feb 2024 04:46:20 +0000 (04:46 +0000)
src/Content/PageInfo.php
src/Content/Text/BBCode.php
src/Model/Item.php
src/Model/Tag.php
src/Module/Profile/Profile.php

index b80a551cb99d421bbac7f243a8d8c6682cc32abb..d59cf5f320606a79ce9f601f1a41ffeadf7c2890 100644 (file)
@@ -170,7 +170,7 @@ class PageInfo
                        foreach ($data['keywords'] as $keyword) {
                                /// @TODO make a positive list of allowed characters
                                $hashtag = str_replace([' ', '+', '/', '.', '#', '@', "'", '"', '’', '`', '(', ')', '„', '“'], '', $keyword);
-                               $hashtags .= '#[url=' . DI::baseUrl() . '/search?tag=' . $hashtag . ']' . $hashtag . '[/url] ';
+                               $hashtags .= '#[url=' . DI::baseUrl() . '/search?tag=' . urlencode($hashtag) . ']' . $hashtag . '[/url] ';
                        }
                }
 
index 0d9e6aaf278b549b545bd373e68426d32848109b..80c3bb229903504d4136f1dff22def952e18e2b6 100644 (file)
@@ -1496,7 +1496,7 @@ class BBCode
 
                                // Replace non graphical smilies for external posts
                                if (!$nosmile) {
-                                       $text = self::performWithEscapedTags($text, ['img'], function ($text) use ($simple_html, $for_plaintext) {
+                                       $text = self::performWithEscapedTags($text, ['url', 'img', 'audio', 'video', 'youtube', 'vimeo', 'share', 'attachment', 'iframe', 'bookmark'], function ($text) use ($simple_html, $for_plaintext) {
                                                return Smilies::replace($text, ($simple_html != self::INTERNAL) || $for_plaintext);
                                        });
                                }
@@ -1961,11 +1961,11 @@ class BBCode
                                self::performWithEscapedTags($text, ['url', 'share'], 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])
+                                                       return '<a href="' . DI::baseUrl() . '/search?tag=' . urlencode($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])
+                                                       return '#<a href="' . DI::baseUrl() . '/search?tag=' . urlencode($matches[1])
                                                                . '" class="tag" rel="tag" title="' . XML::escape($matches[1]) . '">'
                                                                . XML::escape($matches[1]) . '</a>';
                                                }
@@ -2353,7 +2353,7 @@ class BBCode
 
                                        case '#':
                                        default:
-                                               return $match[1] . '[url=' . DI::baseUrl() . '/search?tag=' . rawurlencode($match[2]) . ']' . $match[2] . '[/url]';
+                                               return $match[1] . '[url=' . DI::baseUrl() . '/search?tag=' . urlencode($match[2]) . ']' . $match[2] . '[/url]';
                                }
                        },
                        $body
index aa3a8bc08b4d469588e90c5dc7fd6a7b9c0c66ed..8b43df849bea6a29ec5efda72d88bd6f1d956122 100644 (file)
@@ -2491,7 +2491,7 @@ class Item
                                }
 
                                $basetag = str_replace('_', ' ', substr($tag, 1));
-                               $newtag = '#[url=' . DI::baseUrl() . '/search?tag=' . $basetag . ']' . $basetag . '[/url]';
+                               $newtag = '#[url=' . DI::baseUrl() . '/search?tag=' . urlencode($basetag) . ']' . $basetag . '[/url]';
 
                                $body = str_replace($tag, $newtag, $body);
                        }
index e63a272a753cea7163902d6b49d42429f1db1362..dd9ca079e3628255776144ee77d1a1113a0c7d9c 100644 (file)
@@ -558,7 +558,7 @@ class Tag
                );
                while ($tag = DBA::fetch($taglist)) {
                        if ($tag['url'] == '') {
-                               $tag['url'] = $searchpath . rawurlencode($tag['name']);
+                               $tag['url'] = $searchpath . urlencode($tag['name']);
                        }
 
                        $orig_tag = $tag['url'];
index aeab1eb758aa03275d3a85a0a40f870d0e0ed97b..03ed3e3acf4ad6968ea0f8415cf0e0ee397ea612 100644 (file)
@@ -226,7 +226,7 @@ class Profile extends BaseProfile
                        // Separator is defined in Module\Settings\Profile\Index::cleanKeywords
                        foreach (explode(', ', $profile['pub_keywords']) as $tag_label) {
                                $tags[] = [
-                                       'url'   => '/search?tag=' . $tag_label,
+                                       'url'   => '/search?tag=' . urlencode($tag_label),
                                        'label' => Tag::TAG_CHARACTER[Tag::HASHTAG] . $tag_label,
                                ];
                        }