diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr
index f02afedd..7ab3d0c7 100644
--- a/src/invidious/views/search.ecr
+++ b/src/invidious/views/search.ecr
@@ -1,5 +1,5 @@
<% content_for "header" do %>
-
<%= search_query.not_nil!.size > 30 ? query.not_nil![0,30].rstrip(".") + "..." : query.not_nil! %> - Invidious
+<%= search_query.not_nil!.size > 30 ? HTML.escape(query.not_nil![0,30].rstrip(".") + "...") : HTML.escape(query.not_nil!) %> - Invidious
<% end %>
<% videos.each_slice(4) do |slice| %>
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index bcf20c46..1e31fb4a 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -35,7 +35,7 @@