Fix mc share download for special character encoding
mc share download would fail to generate or generate a wrong signature for a URLs with special unencoded characters. This issue was limited to signature v2.
This commit is contained in:
+25
-3
@@ -142,11 +142,20 @@ func (op *operation) getRequestURL(config Config) (url string) {
|
||||
return
|
||||
}
|
||||
if objectName != "" && queryPath == "" {
|
||||
url += separator + objectName
|
||||
if strings.HasSuffix(url, separator) {
|
||||
url += objectName
|
||||
} else {
|
||||
url += separator + objectName
|
||||
}
|
||||
return
|
||||
}
|
||||
if objectName != "" && queryPath != "" {
|
||||
url += separator + objectName + "?" + queryPath
|
||||
if strings.HasSuffix(url, separator) {
|
||||
url += objectName + "?" + queryPath
|
||||
} else {
|
||||
url += separator + objectName + "?" + queryPath
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -306,7 +315,20 @@ func (r *request) PreSignV2() (string, error) {
|
||||
r.Set("Date", d.Format(http.TimeFormat))
|
||||
}
|
||||
epochExpires := d.Unix() + r.expires
|
||||
signText := fmt.Sprintf("%s\n\n\n%d\n%s", r.req.Method, epochExpires, r.req.URL.Path)
|
||||
var path string
|
||||
if r.config.isVirtualStyle {
|
||||
for k, v := range regions {
|
||||
if v == r.config.Region {
|
||||
path = "/" + strings.TrimSuffix(r.req.URL.Host, "."+k)
|
||||
path += r.req.URL.Path
|
||||
path = getURLEncodedPath(path)
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
path = getURLEncodedPath(r.req.URL.Path)
|
||||
}
|
||||
signText := fmt.Sprintf("%s\n\n\n%d\n%s", r.req.Method, epochExpires, path)
|
||||
hm := hmac.New(sha1.New, []byte(r.config.SecretAccessKey))
|
||||
hm.Write([]byte(signText))
|
||||
|
||||
|
||||
+10
-2
@@ -177,11 +177,19 @@ func (op *operation) getRequestURL(config Config) (url string) {
|
||||
return
|
||||
}
|
||||
if objectName != "" && queryPath == "" {
|
||||
url += separator + objectName
|
||||
if strings.HasSuffix(url, separator) {
|
||||
url += objectName
|
||||
} else {
|
||||
url += separator + objectName
|
||||
}
|
||||
return
|
||||
}
|
||||
if objectName != "" && queryPath != "" {
|
||||
url += separator + objectName + "?" + queryPath
|
||||
if strings.HasSuffix(url, separator) {
|
||||
url += objectName + "?" + queryPath
|
||||
} else {
|
||||
url += separator + objectName + "?" + queryPath
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user