From 0446fc4794d24b52dbf2ac0826a64eb733c1c58d Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Tue, 29 Mar 2022 19:46:29 +0300 Subject: [PATCH] Categories: Ignore empty hypha names and cat names in requests --- web/categories.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web/categories.go b/web/categories.go index 6e30b40..fc42444 100644 --- a/web/categories.go +++ b/web/categories.go @@ -47,6 +47,10 @@ func handlerRemoveFromCategory(w http.ResponseWriter, rq *http.Request) { _, _ = io.WriteString(w, "403 Forbidden") return } + if hyphaName == "" || catName == "" { + http.Redirect(w, rq, redirectTo, http.StatusSeeOther) + return + } categories.RemoveHyphaFromCategory(hyphaName, catName) http.Redirect(w, rq, redirectTo, http.StatusSeeOther) } @@ -63,6 +67,10 @@ func handlerAddToCategory(w http.ResponseWriter, rq *http.Request) { _, _ = io.WriteString(w, "403 Forbidden") return } + if hyphaName == "" || catName == "" { + http.Redirect(w, rq, redirectTo, http.StatusSeeOther) + return + } categories.AddHyphaToCategory(hyphaName, catName) http.Redirect(w, rq, redirectTo, http.StatusSeeOther) }