From c3d00acc4efb698fc992cb162f25cda4b5a78c01 Mon Sep 17 00:00:00 2001 From: qydysky Date: Sun, 16 Feb 2025 03:41:14 +0800 Subject: [PATCH] 1 (#28) --- file/FileWR.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/file/FileWR.go b/file/FileWR.go index 3a854a2..feba846 100644 --- a/file/FileWR.go +++ b/file/FileWR.go @@ -19,6 +19,7 @@ import ( ) var ( + ErrPathEscapes = errors.New("ErrPathEscapes") ErrCopy = errors.New("ErrCopy") ErrGetRW = errors.New("ErrGetRW") ErrFilePathTooLong = errors.New("ErrFilePathTooLong") @@ -634,8 +635,12 @@ func (t *File) Close() error { func (t *File) IsExist() bool { _, err := t.Stat() - if errors.Is(err, ErrFilePathTooLong) { - panic(err) + if err != nil { + if errors.Is(err, ErrFilePathTooLong) { + panic(err) + } else if strings.HasSuffix(err.Error(), "path escapes from parent") { + panic(ErrPathEscapes) + } } return err == nil } -- 2.39.2