@@ -11,6 +11,7 @@ import (
1111 "github.com/OpenListTeam/OpenList/v4/internal/model"
1212 "github.com/OpenListTeam/OpenList/v4/internal/op"
1313 "github.com/OpenListTeam/OpenList/v4/pkg/generic"
14+ "github.com/OpenListTeam/OpenList/v4/pkg/utils"
1415 "github.com/OpenListTeam/OpenList/v4/server/common"
1516 "github.com/gin-gonic/gin"
1617 "github.com/pkg/errors"
@@ -173,6 +174,11 @@ func FsBatchRename(c *gin.Context) {
173174 if renameObject .SrcName == "" || renameObject .NewName == "" {
174175 continue
175176 }
177+ renameObject .NewName , err = utils .CheckRelativePath (renameObject .NewName )
178+ if err != nil {
179+ common .ErrorResp (c , err , 403 )
180+ return
181+ }
176182 filePath := fmt .Sprintf ("%s/%s" , reqPath , renameObject .SrcName )
177183 if err := fs .Rename (c .Request .Context (), filePath , renameObject .NewName ); err != nil {
178184 common .ErrorResp (c , err , 500 )
@@ -228,10 +234,13 @@ func FsRegexRename(c *gin.Context) {
228234 }
229235
230236 for _ , file := range files {
231-
232237 if srcRegexp .MatchString (file .GetName ()) {
238+ newFileName , err := utils .CheckRelativePath (srcRegexp .ReplaceAllString (file .GetName (), req .NewNameRegex ))
239+ if err != nil {
240+ common .ErrorResp (c , err , 403 )
241+ return
242+ }
233243 filePath := fmt .Sprintf ("%s/%s" , reqPath , file .GetName ())
234- newFileName := srcRegexp .ReplaceAllString (file .GetName (), req .NewNameRegex )
235244 if err := fs .Rename (c .Request .Context (), filePath , newFileName ); err != nil {
236245 common .ErrorResp (c , err , 500 )
237246 return
0 commit comments