2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-06 03:47:17 +08:00

feat: 不允许把目录复制到原目录中

This commit is contained in:
耗子
2024-10-27 00:02:29 +08:00
parent b2845fba15
commit 2af4b9569d

View File

@@ -179,6 +179,11 @@ func (s *FileService) Move(w http.ResponseWriter, r *http.Request) {
return
}
if io.IsDir(req.Source) && strings.HasPrefix(req.Target, req.Source) {
Error(w, http.StatusForbidden, "你不能这样做,会玩坏的")
return
}
if err = io.Mv(req.Source, req.Target); err != nil {
Error(w, http.StatusInternalServerError, "%v", err)
return
@@ -199,6 +204,11 @@ func (s *FileService) Copy(w http.ResponseWriter, r *http.Request) {
return
}
if io.IsDir(req.Source) && strings.HasPrefix(req.Target, req.Source) {
Error(w, http.StatusForbidden, "你不能这样做,会玩坏的")
return
}
if err = io.Cp(req.Source, req.Target); err != nil {
Error(w, http.StatusInternalServerError, "%v", err)
return