Commit 18dcc3a
committed
fix(s3): percent-encode object keys in download URLs
`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.1 parent 409da56 commit 18dcc3a
2 files changed
Lines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
80 | 107 | | |
81 | 108 | | |
82 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | | - | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
| |||
0 commit comments