From e4a80edc9572f8bc07638211b946dd1f50121501 Mon Sep 17 00:00:00 2001 From: "John C. Vernaleo" Date: Fri, 14 Jun 2013 11:32:05 -0400 Subject: [PATCH] Clean the error message on connect failure so username and password is not shown. --- jsonfxns.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jsonfxns.go b/jsonfxns.go index 56991b2f..7726cdb9 100644 --- a/jsonfxns.go +++ b/jsonfxns.go @@ -11,6 +11,7 @@ import ( "io" "io/ioutil" "net/http" + "regexp" ) // MarshallAndSend takes the reply structure, marshalls it to json, and @@ -34,7 +35,10 @@ func MarshallAndSend(rawReply Reply, w io.Writer) (string, error) { func jsonRpcSend(user string, password string, server string, message []byte) (*http.Response, error) { resp, err := http.Post("http://"+user+":"+password+"@"+server, "application/json", bytes.NewBuffer(message)) - + // We do not want to log the username/password in the errors. + re := regexp.MustCompile(`http://\w+:\w+`) + errString := re.ReplaceAllString(fmt.Sprintf("%v", err), "") + err = fmt.Errorf(errString) return resp, err }