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:
Harshavardhana
2015-10-13 10:14:26 -07:00
parent 30f08b054f
commit 0f8f5ae6b6
3 changed files with 39 additions and 9 deletions
+25 -3
View File
@@ -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
View File
@@ -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
}
+4 -4
View File
@@ -29,13 +29,13 @@
},
{
"path": "github.com/minio/minio-go",
"revision": "b20214d4c0f52c9efd000d6193fc46a44be44a9e",
"revisionTime": "2015-10-12T10:41:41-07:00"
"revision": "c031bbe3dd5e304e0f0bd154d97615fade8df23b",
"revisionTime": "2015-10-13T10:12:53-07:00"
},
{
"path": "github.com/minio/minio-go-legacy",
"revision": "40941db1ca6fbe97479f5560a83133e6564abfbe",
"revisionTime": "2015-10-12T10:48:42-07:00"
"revision": "49580a230a441dda8eedbf4440f15a4b3018a385",
"revisionTime": "2015-10-13T10:07:00-07:00"
},
{
"path": "github.com/minio/minio/pkg/probe",