You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(storage): avoid double-encoding query params in signed URLs - #2885
Updated createSignedUrl and createSignedUrls in packages/core/storage-js/src/packages/StorageFileApi.ts so encodeURI is applied only to ${this.url}${data.signedURL}, before appending &${queryString} (matching getPublicUrl).
Added unit tests in packages/core/storage-js/test/storageFileApiSignedUrlEncoding.test.ts covering download filenames containing reserved characters (#, &, +) and UTF-8 text.
Why was this change needed?
URLSearchParams already percent-encodes download query parameters in queryString. Wrapping the concatenated URL + queryString in encodeURI(...) re-encoded % sequences (such as # -> %23 -> %2523 and UTF-8 bytes -> %25C3%25A9), corrupting custom download filenames on signed URLs.
I have run pnpm exec prettier --check on the modified files (npx/nx format equivalent for modified package files)
I have added tests for new functionality (pnpm exec jest test/storageFileApiSignedUrlEncoding.test.ts test/storageFileApiUrl.test.ts: 607/607 passed, tsdown build, typedoc, and tsc -p tsconfig.test.json --noEmit passed)
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Bug Fixes
Fixed signed download URLs so special characters and UTF-8 in filenames are handled correctly without double-encoding.
Preserved signed URL paths and tokens, along with failed entries in batch results.
createSignedUrl and createSignedUrls now encode each base signed URL before appending optional query parameters. New tests cover encoded paths and download filenames, check that URLs are not double-encoded, and verify that failed batch entries retain signedUrl: null.
Change: Bug fix
Merge Risk: Minimal · up to 25cf3
Signed URLs with a download filename containing reserved characters or UTF-8 text should no longer be double-encoded. The change is small and has test coverage, and no merge-blocking risk was identified.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What changed?
createSignedUrlandcreateSignedUrlsinpackages/core/storage-js/src/packages/StorageFileApi.tssoencodeURIis applied only to${this.url}${data.signedURL}, before appending&${queryString}(matchinggetPublicUrl).packages/core/storage-js/test/storageFileApiSignedUrlEncoding.test.tscoveringdownloadfilenames containing reserved characters (#,&,+) and UTF-8 text.Why was this change needed?
URLSearchParamsalready percent-encodesdownloadquery parameters inqueryString. Wrapping the concatenated URL +queryStringinencodeURI(...)re-encoded%sequences (such as#->%23->%2523and UTF-8 bytes ->%25C3%25A9), corrupting customdownloadfilenames on signed URLs.Breaking changes
Checklist
<type>(<scope>): <description>pnpm exec prettier --checkon the modified files (npx/nx formatequivalent for modified package files)pnpm exec jest test/storageFileApiSignedUrlEncoding.test.ts test/storageFileApiUrl.test.ts: 607/607 passed,tsdownbuild,typedoc, andtsc -p tsconfig.test.json --noEmitpassed)