]> 127.0.0.1 Git - part/.git/commitdiff
1 (#28) v0.28.20250215194122
authorqydysky <qydysky@foxmail.com>
Sat, 15 Feb 2025 19:41:14 +0000 (03:41 +0800)
committerGitHub <noreply@github.com>
Sat, 15 Feb 2025 19:41:14 +0000 (03:41 +0800)
file/FileWR.go

index 3a854a284d3f666dff09bac3ec9c88fceb439ef0..feba8462319caa84811ddc3fe536ca80314e5ec8 100644 (file)
@@ -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
 }