Skip to content

Commit 7bf6124

Browse files
authored
Do not normalize presigned url object keys in s3 (#3156)
1 parent 8518e27 commit 7bf6124

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

gems/aws-sdk-s3/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Issue - Do not normalize object keys when calling `presigned_url` or `presigned_request`.
5+
46
1.176.0 (2024-12-03)
57
------------------
68

gems/aws-sdk-s3/lib/aws-sdk-s3/presigner.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ def sign_but_dont_send(
238238
credentials_provider: context[:sigv4_credentials] || context.config.credentials,
239239
signing_algorithm: scheme_name.to_sym,
240240
uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
241+
normalize_path: !!!auth_scheme['disableNormalizePath'],
241242
unsigned_headers: unsigned_headers,
242243
apply_checksum_header: false
243244
)

gems/aws-sdk-s3/spec/presigner_spec.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ def initialize(expiration_time)
189189
expect(url).to match(/x-amz-acl=public-read/)
190190
end
191191

192+
it 'does not normalize object keys' do
193+
url = subject.presigned_url(
194+
:get_object,
195+
bucket: 'aws-sdk',
196+
key: 'foo/../bar'
197+
)
198+
expect(url).to include('foo/../bar')
199+
end
200+
192201
context 'credential expiration' do
193202
let(:credentials) do
194203
credentials_provider_class.new(expiration_time)
@@ -331,14 +340,22 @@ def initialize(expiration_time)
331340
end
332341

333342
it 'returns x-amz-* headers instead of hoisting to the query string' do
334-
signer = Presigner.new(client: client)
335-
url, headers = signer.presigned_request(
343+
url, headers = subject.presigned_request(
336344
:put_object, bucket: 'aws-sdk', key: 'foo', acl: 'public-read'
337345
)
338346
expect(url).to match(/X-Amz-SignedHeaders=host%3Bx-amz-acl/)
339347
expect(headers).to eq('x-amz-acl' => 'public-read')
340348
end
341349

350+
it 'does not normalize object keys' do
351+
url, = subject.presigned_request(
352+
:get_object,
353+
bucket: 'aws-sdk',
354+
key: 'foo/../bar'
355+
)
356+
expect(url).to include('foo/../bar')
357+
end
358+
342359
context 'credential expiration' do
343360
let(:credentials) do
344361
credentials_provider_class.new(expiration_time)

0 commit comments

Comments
 (0)