diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index ea9a4737c..549025dec 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -912,7 +912,7 @@ class HTML '$save_label' => $save_label, '$search_hint' => L10n::t('@name, !forum, #tags, content'), '$mode' => $mode, - '$return_url' => urlencode('search?q=' . $s), + '$return_url' => urlencode('search?q=' . urlencode($s)), ]; if (!$aside) { diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 9c0d9e1df..73de090a7 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -63,7 +63,7 @@ class Index extends BaseSearchModule } if (local_user()) { - self::getApp()->page['aside'] .= Widget\SavedSearches::getHTML('search?q=' . $search, $search); + self::getApp()->page['aside'] .= Widget\SavedSearches::getHTML('search?q=' . urlencode($search), $search); } Nav::setSelected('search'); diff --git a/src/Module/Search/Saved.php b/src/Module/Search/Saved.php index 772f4782c..9d8d84b55 100644 --- a/src/Module/Search/Saved.php +++ b/src/Module/Search/Saved.php @@ -10,17 +10,17 @@ use Friendica\Util\Strings; class Saved extends BaseModule { - public static function rawContent() + public static function init() { /** @var Arguments $args */ $args = self::getClass(Arguments::class); $action = $args->get(2, 'none'); - $search = Strings::escapeTags(trim(rawurldecode($args->get(3, '')))); + $search = Strings::escapeTags(trim(rawurldecode($_GET['term'] ?? ''))); $return_url = $_GET['return_url'] ?? 'search?q=' . urlencode($search); - if (local_user()) { + if (local_user() && $search) { switch ($action) { case 'add': $fields = ['uid' => local_user(), 'term' => $search]; diff --git a/static/routes.config.php b/static/routes.config.php index 841fd68f9..c52b5d802 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -191,8 +191,8 @@ return [ '/search' => [ '[/]' => [Module\Search\Index::class, [R::GET]], '/acl' => [Module\Search\Acl::class, [R::GET, R::POST]], - '/saved/add/{term}' => [Module\Search\Saved::class, [R::GET]], - '/saved/remove/{term}' => [Module\Search\Saved::class, [R::GET]], + '/saved/add' => [Module\Search\Saved::class, [R::GET]], + '/saved/remove' => [Module\Search\Saved::class, [R::GET]], ], '/settings' => [ diff --git a/view/templates/searchbox.tpl b/view/templates/searchbox.tpl index d566befba..8317c59b1 100644 --- a/view/templates/searchbox.tpl +++ b/view/templates/searchbox.tpl @@ -11,7 +11,7 @@ {{/if}} {{if $s}} - {{$save_label}} + {{$save_label}} {{/if}} {{/strip}} diff --git a/view/templates/widget/saved_searches.tpl b/view/templates/widget/saved_searches.tpl index 858e921f7..4e3a80b76 100644 --- a/view/templates/widget/saved_searches.tpl +++ b/view/templates/widget/saved_searches.tpl @@ -6,7 +6,7 @@