Added message text new line filtering for reply.
This commit is contained in:
parent
64a51018f6
commit
240a8c389e
@ -108,8 +108,14 @@ func (h *GuestbookApiHandlers) Reply(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if strings.Contains(r.Header.Get("Content-Type"), "application/x-www-form-urlencoded") {
|
if strings.Contains(r.Header.Get("Content-Type"), "application/x-www-form-urlencoded") {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
|
||||||
id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
|
id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
|
||||||
reply, err = guestbook.NewReply(id, r.FormValue("message"))
|
|
||||||
|
message := strings.ReplaceAll(r.FormValue("message"), "\r\n", "\n")
|
||||||
|
message = strings.ReplaceAll(message, "\n\r", "\n")
|
||||||
|
message = strings.ReplaceAll(message, "\r", "\n")
|
||||||
|
|
||||||
|
reply, err = guestbook.NewReply(id, message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@ -128,8 +134,14 @@ func (h *GuestbookApiHandlers) EditReply(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
if strings.Contains(r.Header.Get("Content-Type"), "application/x-www-form-urlencoded") {
|
if strings.Contains(r.Header.Get("Content-Type"), "application/x-www-form-urlencoded") {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
|
||||||
id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
|
id, _ := strconv.ParseInt(GetURLParam(r, "id"), 10, 64)
|
||||||
reply, err = guestbook.NewReply(id, r.FormValue("message"))
|
|
||||||
|
message := strings.ReplaceAll(r.FormValue("message"), "\r\n", "\n")
|
||||||
|
message = strings.ReplaceAll(message, "\n\r", "\n")
|
||||||
|
message = strings.ReplaceAll(message, "\r", "\n")
|
||||||
|
|
||||||
|
reply, err = guestbook.NewReply(id, message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user