@marcel91200 / caddy Mirror · read-only / commits / 94d41a9d
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 05:30 UTC

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

esell committed Mar 3, 2023 at 14:45 UTC 94d41a9d86d6ca2d2d001183a62d762ee045094f
1 file changed +2 -1
modules/caddyhttp/fileserver/staticfiles.go
+2 -1
@@ -250,7 +250,8 @@ func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request, next c
250
251 root := repl.ReplaceAll(fsrv.Root, ".")
252
253 - filename := caddyhttp.SanitizedPathJoin(root, r.URL.Path)
253 + // remove any trailing `/` as it breaks fs.ValidPath() in the stdlib
254 + filename := strings.TrimSuffix(caddyhttp.SanitizedPathJoin(root, r.URL.Path), "/")
255
256 fsrv.logger.Debug("sanitized path join",
257 zap.String("site_root", root),