From 54d846c6c8d3b9a0466bfd6085d61f079f25f23a Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 16 Sep 2021 10:39:47 +0200 Subject: Updated search functionality to limit form interactions --- search/search.go | 6 +++--- search/search.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/search/search.go b/search/search.go index 4b49843..3643cf5 100644 --- a/search/search.go +++ b/search/search.go @@ -102,9 +102,9 @@ type SearchPage struct { // The search handler of the webui func searchHandler(w http.ResponseWriter, r *http.Request) error { p := SearchPage{ - Query: strings.ToLower(r.FormValue("query")), + Query: r.FormValue("query"), } - if p.Query != "" { + if p.Query != "" && len(p.Query) >= 3 && len(p.Query) <= 64 { log.Printf("searching for: %s", p.Query) // First we reset the search options status p.SearchTitle = r.FormValue("searchTitle") == "true" @@ -112,7 +112,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request) error { p.SearchDescription = r.FormValue("searchDescription") == "true" p.SearchContent = r.FormValue("searchContent") == "true" // Then we walk the index - words := normalizeWords(strings.Fields(p.Query)) + words := normalizeWords(strings.Fields(strings.ToLower(p.Query))) scores := make(Pairs, 0) for i := 0; i < len(jsonIndex); i++ { score := 0 diff --git a/search/search.html b/search/search.html index edd598a..e2e24f5 100644 --- a/search/search.html +++ b/search/search.html @@ -1,6 +1,6 @@ {{ define "search" }}
-
+
-- cgit v1.2.3