Skip to content

support object key with characters need to be URI encoded #311

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

Closed
wants to merge 1 commit into from

Conversation

StaymanHou
Copy link

Description of changes:
URI decode the parsed object key in ImageRequest class.
The change can cause missing image if the key existing on S3 is intentionally URI encoded. e.g. If the key of the object stored on S3 is %E4%B8%AD%E6%96%87.jpg, this change will cause the handler to look for object with the key 中文.jpg. The key in the request would have to be double URI decoded (%25E4%25B8%25AD%25E6%2596%2587.jpg) to access that object.

Checklist

  • 👋 I have run the unit tests, and all unit tests have passed.
  • ⚠️ This pull request might incur a breaking change.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@fisenkodv
Copy link
Contributor

@StaymanHou, thank you for your contribution.
We have updated our solution, you can refer to the recent changes here.
Could you please let us know if the changes in this PR are still relevant?

@StaymanHou
Copy link
Author

@fisenkodv, thanks for the follow-up.

I can confirm that this has been resolved with the recent changes. Will submit a PR for the test case shortly.

@StaymanHou
Copy link
Author

Closing the PR.

And for anyone bumps into this issue, to base64 encode utf8 characters in client-side JS, use encodeURIComponent and unescape.

Example

btoa(unescape(encodeURIComponent('{"bucket":"validBucket","key":"中文","edits":{"grayscale":true},"outputFormat":"jpeg"}')))

@StaymanHou StaymanHou closed this Dec 28, 2021
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.

2 participants