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 100ecffda7
révision bfb9bf3239

Voir le fichier

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