s3: fix v2 signer on files with spaces - fixes #2438

Before this fix the v2 signer was failing for files with spaces in.
This commit is contained in:
Nick Craig-Wood 2018-10-09 13:05:18 +01:00
parent 0f02c9540c
commit dbedf33b9f

View File

@ -44,16 +44,7 @@ func sign(AccessKey, SecretKey string, req *http.Request) {
req.Header.Set("Date", date)
// Sort out URI
uri := req.URL.Opaque
if uri != "" {
if strings.HasPrefix(uri, "//") {
// Strip off //host/uri
uri = "/" + strings.Join(strings.Split(uri, "/")[3:], "/")
req.URL.Opaque = uri // reset to plain URI otherwise Ceph gets confused
}
} else {
uri = req.URL.Path
}
uri := req.URL.EscapedPath()
if uri == "" {
uri = "/"
}