Skip to content

fix(s3): percent-encode object keys in download URLs#872

Merged
PaulHax merged 1 commit intoKitware:mainfrom
PaulHax:s3-key-encoding
May 8, 2026
Merged

fix(s3): percent-encode object keys in download URLs#872
PaulHax merged 1 commit intoKitware:mainfrom
PaulHax:s3-key-encoding

Conversation

@PaulHax
Copy link
Copy Markdown
Collaborator

@PaulHax PaulHax commented May 8, 2026

S3 keys may contain ?, #, space, +, etc. (per AWS object-key rules), and ListObjectsV2 returns them verbatim. getObjectPublicUrl interpolated keys raw, so e.g. scan?1.dcm was sent as GET /scan?1.dcm (404) and seg#1.dcm lost its #1.dcm to the fragment.

Split on /, encodeURIComponent each segment. Tests cover ?, #, space, +, and a multi-segment key.

`getObjectPublicUrl` interpolated S3 keys directly into the URL path. S3
keys may legally contain reserved URI delimiters (`?`, `#`), space, `+`,
etc., per AWS object key naming guidelines, and `ListObjectsV2` returns
them verbatim. Per RFC 3986, `?` starts a query string and `#` a fragment,
so a key like `scan?1.dcm` was sent as `GET /scan?1.dcm` (object `scan` +
query `1.dcm` => 404), and `seg#1.dcm` had its fragment stripped before
the request even left the browser.

Split keys on `/` and `encodeURIComponent` each segment to preserve the
hierarchy while encoding everything else.

Tests cover `?`, `#`, space, `+`, and a multi-segment key.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 8, 2026

Deploy Preview for volview-dev ready!

Name Link
🔨 Latest commit 0f432c8
🔍 Latest deploy log https://app.netlify.com/projects/volview-dev/deploys/69fdf07b5b82040008aa7217
😎 Deploy Preview https://deploy-preview-872--volview-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@PaulHax PaulHax added this pull request to the merge queue May 8, 2026
Merged via the queue into Kitware:main with commit 18dcc3a May 8, 2026
8 of 9 checks passed
@PaulHax PaulHax deleted the s3-key-encoding branch May 8, 2026 15:31
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