From 7c1327654c44ceb91149ed5f896fbc558091cde5 Mon Sep 17 00:00:00 2001 From: Gregor Best <gbe@unobtanium.de> Date: Sun, 11 Apr 2021 19:42:11 +0200 Subject: [PATCH] Enfore a maximum length on the name --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 9352de0..9808d5c 100644 --- a/main.go +++ b/main.go @@ -64,13 +64,17 @@ func main() { // TODO: load/store image - // TODO: Validate max. length name := r.FormValue("name") if name == "" { http.Error(w, "name empty or missing", http.StatusBadRequest) return } + if len(name) > 80 { + http.Error(w, "name too long, max length is 80", http.StatusBadRequest) + return + } + ratingVal := r.FormValue("rating") rating, err := strconv.Atoi(ratingVal) if err != nil { -- GitLab