From 2f6e4992a49f1e233a48793eb797219bb2305d80 Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Mon, 12 Apr 2021 09:51:19 +0200 Subject: [PATCH] fix missing return statements and additional broken xml logging --- app/pingback/handler.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/pingback/handler.go b/app/pingback/handler.go index a125888..17dfbd3 100644 --- a/app/pingback/handler.go +++ b/app/pingback/handler.go @@ -15,16 +15,18 @@ func HandlePost(conf *common.Config) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { body, err := ioutil.ReadAll(r.Body) if err != nil { - pingbackError(w, "Unable to read request body") + pingbackError(w, "Unable to read request body", []byte("")) + return } rpc := &XmlRPCMethodCall{} err = xml.Unmarshal(body, rpc) if err != nil { - pingbackError(w, "Unable to unmarshal XMLRPC request body") + pingbackError(w, "Unable to unmarshal XMLRPC request body", body) + return } if !validate(rpc, conf) { - pingbackError(w, "malformed pingback request") + pingbackError(w, "malformed pingback request", body) return } @@ -59,7 +61,7 @@ func pingbackSuccess(w http.ResponseWriter) { } // according to the XML-RPC spec, always return a 200, but encode it into the XML. -func pingbackError(w http.ResponseWriter, msg string) { +func pingbackError(w http.ResponseWriter, msg string, body []byte) { xml := ` @@ -89,7 +91,7 @@ func pingbackError(w http.ResponseWriter, msg string) { ` - log.Error().Str("msg", msg).Msg("Pingback receive went wrong") + log.Error().Str("msg", msg).Str("xml", string(body)).Msg("Pingback receive went wrong") w.WriteHeader(200) w.Write([]byte(xml)) }