aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/fileserver/browse.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2022-07-07 14:10:19 -0600
committerMatthew Holt <[email protected]>2022-07-07 14:10:19 -0600
commitc0f76e9ed482b0abde0c3d8f5e26e9f015418ca3 (patch)
tree07704aa79a181d740024c0ceaab1723791ccc341 /modules/caddyhttp/fileserver/browse.go
parentf259ed52bb3764ce4fd5d88f1712cb43247c2639 (diff)
downloadcaddy-c0f76e9ed482b0abde0c3d8f5e26e9f015418ca3.tar.gz
caddy-c0f76e9ed482b0abde0c3d8f5e26e9f015418ca3.zip
fileserver: Use safe redirects in file browser
Diffstat (limited to 'modules/caddyhttp/fileserver/browse.go')
-rw-r--r--modules/caddyhttp/fileserver/browse.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/modules/caddyhttp/fileserver/browse.go b/modules/caddyhttp/fileserver/browse.go
index f308281a3..d59010d28 100644
--- a/modules/caddyhttp/fileserver/browse.go
+++ b/modules/caddyhttp/fileserver/browse.go
@@ -67,9 +67,7 @@ func (fsrv *FileServer) serveBrowse(root, dirPath string, w http.ResponseWriter,
if r.URL.Path == "" || path.Base(origReq.URL.Path) == path.Base(r.URL.Path) {
if !strings.HasSuffix(origReq.URL.Path, "/") {
fsrv.logger.Debug("redirecting to trailing slash to preserve hrefs", zap.String("request_path", r.URL.Path))
- origReq.URL.Path += "/"
- http.Redirect(w, r, origReq.URL.String(), http.StatusMovedPermanently)
- return nil
+ return redirect(w, r, origReq.URL.Path+"/")
}
}