bucket.Put with object keys with spaces fails (fix included)

Bug #1087338 reported by Robert Carlsen
28
This bug affects 5 people
Affects Status Importance Assigned to Milestone
goamz
Confirmed
Undecided
Unassigned

Bug Description

The s3 request signing process signs a payload with an unescaped path. When amazon checks the signature, it does so on an escaped version of the path (containing the object key/name). All put requests with spaces in object keys fail with "The request signature we calculated does not match the signature you provided. Check your key and signing method.".

The fix I am using now is to escape "canonicalPath" var before passing it to the sign function. A diff of the fix below:

=== modified file 's3/s3.go'
--- s3/s3.go 2012-07-19 13:51:13 +0000
+++ s3/s3.go 2012-12-06 16:49:38 +0000
@@ -396,6 +396,7 @@
        if err != nil {
                return fmt.Errorf("bad S3 endpoint URL %q: %v", req.baseurl, err)
        }
+ canonicalPath = (&url.URL{Path: canonicalPath}).String()
        req.headers["Host"] = []string{u.Host}
        req.headers["Date"] = []string{time.Now().In(time.UTC).Format(time.RFC1123)}
        sign(s3.Auth, req.method, canonicalPath, req.params, req.headers)

Revision history for this message
Paul Nakata (pmn) wrote :

The suggested fix resolves the issue for me.

summary: - bucket.Put with object keys with spaces fails
+ bucket.Put with object keys with spaces fails (fix included)
Revision history for this message
Reed O'Brien (reedobrien) wrote :

As of this writing I used the attached to make this work

Changed in goamz:
status: New → Confirmed
Revision history for this message
Christopher Proto (chroto24) wrote :

The original patch no longer applies but the issue still exists.

This new patch should be applicable to trunk

Revision history for this message
Adam Venturella (aventurella) wrote :

This patch fixes it for me as well. I wasted a good few hours before I found this was the issue. This patch should be merged in, or an alternate solution provided.

Revision history for this message
Akshay (a-projects) wrote :

Lets merge this in please. It effects basic PUT functionality.

Revision history for this message
Herman Schaaf (herman-5) wrote :

The latest patch fixes the issue for me as well. It might be worth noting that this does not only affect files with spaces in the name, but also files with non-ASCII character names (台湾.csv, for example)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.