1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

fileserver: Remove trailing slash on fs filenames (#5417)

This commit is contained in:
esell 2023-03-03 14:45:17 -07:00 committed by GitHub
parent 99d47050e9
commit 94d41a9d86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -250,7 +250,8 @@ func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request, next c
root := repl.ReplaceAll(fsrv.Root, ".")
filename := caddyhttp.SanitizedPathJoin(root, r.URL.Path)
// remove any trailing `/` as it breaks fs.ValidPath() in the stdlib
filename := strings.TrimSuffix(caddyhttp.SanitizedPathJoin(root, r.URL.Path), "/")
fsrv.logger.Debug("sanitized path join",
zap.String("site_root", root),