@marcel91200 / caddy Mirror · read-only / commits / 2be56c52
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, 09:15 UTC

fileserver: Treat invalid file path as NotFound (#5099)

treat invalid file path as notFound so that PassThru can work

xufanglu committed Oct 5, 2022 at 11:32 UTC 2be56c526c9652911883905eb91abaf5fdf821fb
1 file changed +1 -1
modules/caddyhttp/fileserver/staticfiles.go
+1 -1
@@ -247,7 +247,7 @@ func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request, next c
247 info, err := fs.Stat(fsrv.fileSystem, filename)
248 if err != nil {
249 err = fsrv.mapDirOpenError(err, filename)
250 - if errors.Is(err, fs.ErrNotExist) {
250 + if errors.Is(err, fs.ErrNotExist) || errors.Is(err, fs.ErrInvalid) {
251 return fsrv.notFound(w, r, next)
252 } else if errors.Is(err, fs.ErrPermission) {
253 return caddyhttp.Error(http.StatusForbidden, err)