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

treat invalid file path as notFound so that PassThru can work
This commit is contained in:
xufanglu 2022-10-05 11:32:40 +08:00 committed by GitHub
parent 01e192edc9
commit 2be56c526c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -247,7 +247,7 @@ func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request, next c
info, err := fs.Stat(fsrv.fileSystem, filename)
if err != nil {
err = fsrv.mapDirOpenError(err, filename)
if errors.Is(err, fs.ErrNotExist) {
if errors.Is(err, fs.ErrNotExist) || errors.Is(err, fs.ErrInvalid) {
return fsrv.notFound(w, r, next)
} else if errors.Is(err, fs.ErrPermission) {
return caddyhttp.Error(http.StatusForbidden, err)