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');