Skip to content

fix: Correctly canonicalize query param spaces#18

Open
lionel-rowe wants to merge 2 commits intolucacasonato:mainfrom
lionel-rowe:canonicalize-query-param-spaces
Open

fix: Correctly canonicalize query param spaces#18
lionel-rowe wants to merge 2 commits intolucacasonato:mainfrom
lionel-rowe:canonicalize-query-param-spaces

Conversation

@lionel-rowe
Copy link

@lionel-rowe lionel-rowe commented Feb 15, 2023

This, along with lucacasonato/deno_s3#55, will fix lucacasonato/deno_s3#54.

URLSearchParams#toString() canonicalizes spaces in keys or values to +:

new URL('https://example.com/?a%20b=c%20d').searchParams.toString() // 'a+b=c+d'

Whereas AWS requires them to be percent-encoded. Per https://docs.aws.amazon.com/general/latest/gr/create-signed-request.html#create-canonical-request:

CanonicalQueryString – The URL-encoded query string parameters, separated by ampersands (&). Percent-encode reserved characters, including the space character.

@benatkin
Copy link

I'm interested in this library, and I think I would need this to be able to use it.

I saw there's a test in the s3 PR, perhaps one could be added here as well?

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

Successfully merging this pull request may close these issues.

Prefix key containing space throws S3Error with 403 SignatureDoesNotMatch response

2 participants