mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-05-24 10:58:15 +08:00
chore: disallow symlink in unzip
This commit is contained in:
parent
608ddb1b44
commit
ed42c4feb8
@ -224,10 +224,14 @@ func unzip(src, dest string) (string, error) {
|
|||||||
if !strings.HasPrefix(fpath, filepath.Clean(dest)+string(os.PathSeparator)) {
|
if !strings.HasPrefix(fpath, filepath.Clean(dest)+string(os.PathSeparator)) {
|
||||||
return "", fmt.Errorf("invalid file path: %s", fpath)
|
return "", fmt.Errorf("invalid file path: %s", fpath)
|
||||||
}
|
}
|
||||||
if f.FileInfo().IsDir() {
|
info := f.FileInfo()
|
||||||
|
if info.IsDir() {
|
||||||
os.MkdirAll(fpath, os.ModePerm)
|
os.MkdirAll(fpath, os.ModePerm)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if info.Mode()&os.ModeSymlink != 0 {
|
||||||
|
continue // disallow symlink
|
||||||
|
}
|
||||||
if err = os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil {
|
if err = os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user