summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxufanglu <3146974+likev@users.noreply.github.com>2022-10-05 11:32:40 +0800
committerGitHub <noreply@github.com>2022-10-04 21:32:40 -0600
commit2be56c526c9652911883905eb91abaf5fdf821fb (patch)
tree6a50bc22a643b69ab23dd7c02a0a1abde02e2314
parent01e192edc9e11ceb92dd02eb79efde087838831a (diff)
fileserver: Treat invalid file path as NotFound (#5099)
treat invalid file path as notFound so that PassThru can work
-rw-r--r--modules/caddyhttp/fileserver/staticfiles.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go
index 8474338..04728ce 100644
--- a/modules/caddyhttp/fileserver/staticfiles.go
+++ b/modules/caddyhttp/fileserver/staticfiles.go
@@ -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)