From: qydysky Date: Sat, 15 Feb 2025 19:41:14 +0000 (+0800) Subject: 1 (#28) X-Git-Tag: v0.28.20250215194122 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=c3d00acc4efb698fc992cb162f25cda4b5a78c01;p=part%2F.git 1 (#28) --- 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 }