Skip to content

Commit f43904f

Browse files
authored
Do not encode asterisks on requests (#130)
1 parent ff1e559 commit f43904f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/network.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ func encodeRequestParams(params url.Values) string {
120120
}
121121
buf.WriteString(key)
122122
buf.WriteString("=")
123-
buf.WriteString(url.QueryEscape(value))
123+
escaped := url.QueryEscape(value)
124+
// we need to ensure + (representing a space) is encoded as %20
125+
escaped = strings.Replace(escaped, "+", "%20", -1)
126+
// we need to ensure * is not escaped
127+
escaped = strings.Replace(escaped, "%2A", "*", -1)
128+
buf.WriteString(escaped)
124129
}
125130
return buf.String()
126131
}
@@ -204,7 +209,7 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
204209
encodedParams = encodeRequestParams(params)
205210

206211
mac := hmac.New(sha1.New, []byte(secretKey))
207-
mac.Write([]byte(strings.Replace(strings.ToLower(encodedParams), "+", "%20", -1)))
212+
mac.Write([]byte(strings.ToLower(encodedParams)))
208213
signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))
209214
encodedParams = encodedParams + fmt.Sprintf("&signature=%s", url.QueryEscape(signature))
210215
} else if len(r.Config.ActiveProfile.Username) > 0 && len(r.Config.ActiveProfile.Password) > 0 {

0 commit comments

Comments
 (0)