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),