mirror of
https://github.com/acepanel/panel.git
synced 2026-02-06 03:47:17 +08:00
feat: 不允许把目录复制到原目录中
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user