From 6006405e743a61e6e7386e8a6b020489e0b7c46d Mon Sep 17 00:00:00 2001 From: Donovan Kolbly Date: Thu, 6 Nov 2014 14:33:41 -0600 Subject: [PATCH 1/2] Replace "+" in object queries with "%2B" This fixes issue #259 in which objects with "+" in the object key cannot be retrieved. --- s3/s3.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s3/s3.go b/s3/s3.go index 6d00816c..b14ae429 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -949,7 +949,7 @@ func partiallyEscapedPath(path string) string { } } } - return strings.Join(pathEscapedAndSplit, "/") + return strings.Replace(strings.Join(pathEscapedAndSplit, "/"), "+", "%2B", -1) } // prepare sets up req to be delivered to S3. From ecb71ce1281a4e85644228306ba41309c232b4c8 Mon Sep 17 00:00:00 2001 From: Donovan Kolbly Date: Thu, 6 Nov 2014 15:00:40 -0600 Subject: [PATCH 2/2] Added test case for %2B-expansion of "+" in object names It turns out that req.URL is already processed, so it would come back as "has+plus" both with and without the fix, but req.RequestURI is not %-expanded so works to verify this fix. --- s3/s3_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/s3/s3_test.go b/s3/s3_test.go index aafa0aff..59b56322 100644 --- a/s3/s3_test.go +++ b/s3/s3_test.go @@ -115,6 +115,17 @@ func (s *S) TestGet(c *check.C) { c.Assert(string(data), check.Equals, "content") } +func (s *S) TestGetWithPlus(c *check.C) { + testServer.Response(200, nil, "content") + + b := s.s3.Bucket("bucket") + _, err := b.Get("has+plus") + + req := testServer.WaitRequest() + c.Assert(err, check.IsNil) + c.Assert(req.RequestURI, check.Equals, "http://localhost:4444/bucket/has%2Bplus") +} + func (s *S) TestURL(c *check.C) { testServer.Response(200, nil, "content")