diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2022-07-07 14:10:19 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2022-07-07 14:10:19 -0600 |
commit | c0f76e9ed482b0abde0c3d8f5e26e9f015418ca3 (patch) | |
tree | 07704aa79a181d740024c0ceaab1723791ccc341 /modules/caddyhttp | |
parent | f259ed52bb3764ce4fd5d88f1712cb43247c2639 (diff) |
fileserver: Use safe redirects in file browser
Diffstat (limited to 'modules/caddyhttp')
-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 f308281..d59010d 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+"/") } } |