Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3 should escape "+" with "%2B" in object key #259

Closed
dkolbly opened this issue Nov 6, 2014 · 1 comment
Closed

s3 should escape "+" with "%2B" in object key #259

dkolbly opened this issue Nov 6, 2014 · 1 comment

Comments

@dkolbly
Copy link
Contributor

dkolbly commented Nov 6, 2014

Attempting to Get() an object whose key includes a "+" character results in a 404 error (if I have List permission on the bucket, that is; otherwise, I get a 403). It looks like partiallyEscapedPath should be escaping "+" with "%2B" but isn't.

I can't find any specific mention of this rule in the AWS documentation except where it talks about request signing (see also issue #243).

Here is a test program:

package main

import (
    "log"
    "fmt"
    "github.com/crowdmob/goamz/aws"
    "github.com/crowdmob/goamz/s3"
)

func AWS() aws.Auth {
    auth, err := aws.EnvAuth()
    if err != nil {
        log.Fatal(err)
    }
    return auth
}

// Region returns the region for use by the aws package
func Region() aws.Region {
    rgn, ok := aws.Regions["us-east-1"]
    if !ok {
        log.Fatal("Unknown region")
    }
    return rgn
}

func main() {
    s3 := s3.New(AWS(), Region())
    b := s3.Bucket("rscheme-docker")
    data, err := b.Get("test/test+plus.now")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Data is: %q\n", data)
}

which produces the following output (with s3.go's debug flag set to true):

2014/11/06 14:27:56 Signature payload: "GET\n\n\nThu, 06 Nov 2014 20:27:56 UTC\n/rscheme-docker/test/test+plus.now"
2014/11/06 14:27:56 Signature: "<redacted>"
2014/11/06 14:27:56 Running S3 request: &s3.request{method:"GET", bucket:"rscheme-docker", path:"/rscheme-docker/test/test+plus.now", params:url.Values{}, headers:http.Header{"Host":[]string{"s3.amazonaws.com"}, "Date":[]string{"Thu, 06 Nov 2014 20:27:56 UTC"}, "Authorization":[]string{"AWS <redacted>"}}, baseurl:"https://s3.amazonaws.com", payload:?reflect.Value?, prepared:true}
2014/11/06 14:27:57 } -> HTTP/1.1 404 Not Found
Connection: close
Transfer-Encoding: chunked
Content-Type: application/xml
Date: Thu, 06 Nov 2014 20:27:57 GMT
Server: AmazonS3
X-Amz-Id-2: <redacted>
X-Amz-Request-Id: E886DA21B6EA0191

115
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>test/test plus.now</Key><RequestId>E886DA21B6EA0191</RequestId><HostId>DAO074akQn94Raa/Q4fqCKelHlisazuIXVTCujiFCDgkjPiOvR7SWxBLL2ZQ3FLt</HostId></Error>
0


2014/11/06 14:27:57 got error (status code 404)
2014/11/06 14:27:57     data:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>test/test plus.now</Key><RequestId>E886DA21B6EA0191</RequestId><HostId>DAO074akQn94Raa/Q4fqCKelHlisazuIXVTCujiFCDgkjPiOvR7SWxBLL2ZQ3FLt</HostId></Error>

2014/11/06 14:27:57 err: s3.Error{StatusCode:404, Code:"NoSuchKey", Message:"The specified key does not exist.", BucketName:"", RequestId:"E886DA21B6EA0191", HostId:"DAO074akQn94Raa/Q4fqCKelHlisazuIXVTCujiFCDgkjPiOvR7SWxBLL2ZQ3FLt"}
2014/11/06 14:27:57 The specified key does not exist.
dkolbly pushed a commit to dkolbly/goamz that referenced this issue Nov 6, 2014
This fixes issue AdRoll#259 in which objects with "+" in the
object key cannot be retrieved.
@dkolbly
Copy link
Contributor Author

dkolbly commented Nov 7, 2014

This is fixed and merged now with PR #260

@dkolbly dkolbly closed this as completed Nov 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant