Skip to content

Commit

Permalink
Bug fix on url decoding keys.
Browse files Browse the repository at this point in the history
Fixes #828
  • Loading branch information
trevorrowe committed May 29, 2015
1 parent 15de059 commit be9b131
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Unreleased Changes
------------------

* Issue - Aws::S3 - Resolved an issue with the URL decoding of keys in the
response to a call to `Aws::S3::Client#list_objects`.

See [related GitHub issue #828](https://github.com/aws/aws-sdk-ruby/pull/828)

2.0.47 (2015-05-28)
------------------

Expand All @@ -23,7 +28,7 @@ Unreleased Changes
* Feature - Aws::ElasticTranscoder - Elastic Transcoder now supports additional
formats, including MXF, FLAC, and OGA, and additional flexibility for your
output audio. You can use these formats to transcode files to the XDCAM format
or to a lossless audio format.
or to a lossless audio format.

* Feature - Aws::Kinesis - The Amazon Kinesis API `#get_records` now includes a
new parameter `:millis_behind_latest`: the number of milliseconds the
Expand Down
8 changes: 8 additions & 0 deletions aws-sdk-core/features/s3/objects.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ Feature: S3 Objects
When I get an object that doesn't exist with a read block
Then an error should be raise and the block should not yield

Scenario: URL decoding Keys
Given I put "data1" to the key "a b"
And I put "data2" to the key "a+b"
Then the keys in my bucket should be
| keys |
| a b |
| a+b |

@paging
Scenario: Paging responses
Given I put nothing to the key "photos/camping/cascades.jpg"
Expand Down
5 changes: 5 additions & 0 deletions aws-sdk-core/features/s3/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,8 @@ def create_bucket(options = {})
resp = @client.list_objects(bucket: @bucket_name, prefix: key, max_keys: 1)
expect(resp.contents.first.storage_class).to eq(sc)
end

Then(/^the keys in my bucket should be$/) do |table|
keys = @client.list_objects(bucket:@bucket_name).contents.map(&:key)
expect(keys.sort).to eq(table.rows.map(&:first).sort)
end
6 changes: 3 additions & 3 deletions aws-sdk-core/lib/aws-sdk-core/plugins/s3_url_encoded_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def decode_list_multipart_uploads_keys(data)

def decode(member, struct)
if struct[member]
struct[member] = URI.decode(struct[member])
struct[member] = CGI.unescape(struct[member])
end
end

end

handler(Handler,
step: :build,
priority: 60, # run this just before/after the XML builder/parser
step: :validate,
priority: 0,
operations: [
:list_objects,
:list_object_versions,
Expand Down
3 changes: 2 additions & 1 deletion aws-sdk-core/spec/aws/s3/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ module S3
Seahorse::Client::Response.new(context: context)
end
resp = client.list_objects(bucket:'aws-sdk')
expect(resp.context.http_request.endpoint.query).to include('encoding-type=url')
expect(resp.context.params[:encoding_type]).to eq('url')
expect(resp.data.to_h).to eq({
prefix: 'a&',
Expand Down Expand Up @@ -416,7 +417,7 @@ module S3
end
resp = client.list_objects(bucket:'aws-sdk')
expect(resp.contents.map(&:key)).to eq([
'prefix+suffix',
'prefix suffix',
'prefix+suffix',
'prefix suffix',
])
Expand Down

0 comments on commit be9b131

Please sign in to comment.