Skip to content

Commit

Permalink
fileserver: Remove trailing slash on fs filenames (#5417)
Browse files Browse the repository at this point in the history
  • Loading branch information
esell authored Mar 3, 2023
1 parent 99d4705 commit 94d41a9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/caddyhttp/fileserver/staticfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 94d41a9

Please sign in to comment.