Skip to content

Commit

Permalink
Add even better spam protection for empty forms
Browse files Browse the repository at this point in the history
  • Loading branch information
johanngyger committed Feb 16, 2022
1 parent 25176ae commit 7aef6ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ func validateForm(req *http.Request, isNewsletter bool) error {
}

if req.FormValue("url") != "" {
return fmt.Errorf("form submission is probably spam, gonna ditch it")
return fmt.Errorf("form fiels url is not empty, which is probably spam")
}

if len(req.PostForm) == 0 {
return fmt.Errorf("form is empty, which is probably spam")
}

for k := range req.PostForm {
Expand Down

0 comments on commit 7aef6ff

Please sign in to comment.