Fix empty comment (sanitize then trim and check) (#368)
Cette révision appartient à :
Parent
100ecffda7
révision
bfb9bf3239
1 fichiers modifiés avec 5 ajouts et 5 suppressions
|
@ -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
|
||||||
|
|
Référencer dans un nouveau ticket