diff options
author | Matthew Holt <[email protected]> | 2022-07-07 14:10:19 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2022-07-07 14:10:19 -0600 |
commit | c0f76e9ed482b0abde0c3d8f5e26e9f015418ca3 (patch) | |
tree | 07704aa79a181d740024c0ceaab1723791ccc341 /modules/caddyhttp/fileserver/browse.go | |
parent | f259ed52bb3764ce4fd5d88f1712cb43247c2639 (diff) | |
download | caddy-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.go | 4 |
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+"/") } } |