Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix empty comment (sanitize then trim and check) (#368)

Cette révision appartient à :
tomleb 2017-05-11 15:46:14 -04:00 révisé par Austin
Parent c1392a52d9
révision beb27c50f2

Voir le fichier

@ -39,11 +39,6 @@ func PostCommentHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
id := vars["id"]
if strings.TrimSpace(r.FormValue("comment")) == "" {
http.Error(w, "comment empty", 406)
return
}
userCaptcha := captcha.Extract(r)
if !captcha.Authenticate(userCaptcha) {
http.Error(w, "bad captcha", 403)
@ -52,6 +47,11 @@ func PostCommentHandler(w http.ResponseWriter, r *http.Request) {
currentUser := GetUser(r)
content := p.Sanitize(r.FormValue("comment"))
if strings.TrimSpace(content) == "" {
http.Error(w, "comment empty", 406)
return
}
idNum, err := strconv.Atoi(id)
userID := currentUser.ID