Skip to content

Commit 16d89a5

Browse files
committed
Fix redirect for directories to escape special chars in URL
Directories with a "%" in their name do not work correctly when when redirected to a URL with a trailing slash. When the original URl contains special characters, such as "%", the correcponding redirect URL must escape these characters. Fixes issue ipfs/kubo#10536
1 parent 85fbc3a commit 16d89a5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ The following emojis are used to highlight certain changes:
2222

2323
### Fixed
2424

25+
- `gateway` Fix links for subdirectories with "%" in name. [#779](https://github.com/ipfs/boxo/pull/779)
26+
2527
### Security
2628

2729

gateway/handler_unixfs_dir.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (i *handler) serveDirectory(ctx context.Context, w http.ResponseWriter, r *
5050
suffix = suffix + "?" + r.URL.RawQuery
5151
}
5252
// /ipfs/cid/foo?bar must be redirected to /ipfs/cid/foo/?bar
53-
redirectURL := originalURLPath + suffix
53+
redirectURL := requestURI.EscapedPath() + suffix
5454
rq.logger.Debugw("directory location moved permanently", "status", http.StatusMovedPermanently)
5555
http.Redirect(w, r, redirectURL, http.StatusMovedPermanently)
5656
return true

0 commit comments

Comments
 (0)