[server] Add validation for object_keys (#4022)

## Description

## Tests
This commit is contained in:
Manav Rathi
2024-11-13 15:24:18 +05:30
committed by GitHub

View File

@@ -64,6 +64,9 @@ func (c *FileController) validateFileCreateOrUpdateReq(userID int64, file ente.F
if !strings.HasPrefix(file.File.ObjectKey, objectPathPrefix) || !strings.HasPrefix(file.Thumbnail.ObjectKey, objectPathPrefix) {
return stacktrace.Propagate(ente.ErrBadRequest, "Incorrect object key reported")
}
if file.File.ObjectKey == file.Thumbnail.ObjectKey {
return stacktrace.Propagate(ente.ErrBadRequest, "file and thumbnail object keys are same")
}
isCreateFileReq := file.ID == 0
// Check for attributes for fileCreation. We don't send key details on update
if isCreateFileReq {