Skip to content

fix(storage): avoid double-encoding query params in signed URLs - #2885

Open
shafiktanbir wants to merge 1 commit into
supabase:masterfrom
shafiktanbir:fix/storage-avoid-double-encoding-signed-url-query
Open

shafiktanbir wants to merge 1 commit into
supabase:masterfrom
shafiktanbir:fix/storage-avoid-double-encoding-signed-url-query

Conversation

@shafiktanbir

Copy link
Copy Markdown

Description

What changed?

  • 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.

Breaking changes

  • This PR contains no breaking changes

Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • 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)

@shafiktanbir
shafiktanbir requested review from a team as code owners November 22, 2026 19:16
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 12000477-c9f1-4f7c-b3bc-1d23dc77c472
Commits

Reviewing files that changed from the base of the PR and between 840843d and 25cf33f.

Files selected for processing: 2

  • packages/core/storage-js/src/packages/StorageFileApi.ts
  • packages/core/storage-js/test/storageFileApiSignedUrlEncoding.test.ts

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 branch has not been deployed

No deployments
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.

1 participant