diff options
author | esell <esell@users.noreply.github.com> | 2023-03-03 14:45:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 14:45:17 -0700 |
commit | 94d41a9d86d6ca2d2d001183a62d762ee045094f (patch) | |
tree | cc20f661152b4a59d638777ec42bf3f6cd268ef8 | |
parent | 99d47050e97a8ccac2aad3bda46be46d4fec85ed (diff) |
fileserver: Remove trailing slash on fs filenames (#5417)
-rw-r--r-- | modules/caddyhttp/fileserver/staticfiles.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go index c0fde66..0459b3a 100644 --- a/modules/caddyhttp/fileserver/staticfiles.go +++ b/modules/caddyhttp/fileserver/staticfiles.go @@ -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), |