From a5b1a31e073d67be0215e68ce3714b2cfd661bfd Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sat, 20 Sep 2014 19:05:38 -0500 Subject: [PATCH] Use the net package function for credentials. This change ensures any usernames or passwords which contain symbols that would confuse the URL parser are properly escaped. --- jsonfxns.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsonfxns.go b/jsonfxns.go index df4a16b7..baa45b65 100644 --- a/jsonfxns.go +++ b/jsonfxns.go @@ -15,6 +15,7 @@ import ( "io" "io/ioutil" "net/http" + "net/url" "strings" ) @@ -52,7 +53,7 @@ func jsonRPCSend(user string, password string, server string, message []byte, client.Transport = transport protocol = "https" } - credentials := user + ":" + password + credentials := url.UserPassword(user, password).String() resp, err := client.Post(protocol+"://"+credentials+"@"+server, "application/json", bytes.NewReader(message)) if err != nil {