mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-09-12 21:58:58 -04:00
graph: check the special folder name explicitly in each handler
This commit is contained in:
1 parent
7469ab05c7
commit
88ca2a6269
2 files changed
+28
-21
No files matched your search
@@ -27,8 +27,13 @@ const RecycleBinSpecialFolderName = "recyclebin"
|
||||
func (g Graph) GetDriveSpecial(w http.ResponseWriter, r *http.Request) {
|
||||
g.logger.Debug().Msg("Calling GetDriveSpecial")
|
||||
|
||||
driveID, ok := parseSpecialParams(w, r)
|
||||
if !ok {
|
||||
driveID, err := parseIDParam(r, "driveID")
|
||||
if err != nil {
|
||||
errorcode.RenderError(w, r, err)
|
||||
return
|
||||
}
|
||||
if chi.URLParam(r, "specialName") != RecycleBinSpecialFolderName {
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "unknown special folder")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -88,8 +93,13 @@ func (g Graph) findRecycleItem(w http.ResponseWriter, r *http.Request, driveID *
|
||||
func (g Graph) ListDriveSpecialChildren(w http.ResponseWriter, r *http.Request) {
|
||||
g.logger.Debug().Msg("Calling ListDriveSpecialChildren")
|
||||
|
||||
driveID, ok := parseSpecialParams(w, r)
|
||||
if !ok {
|
||||
driveID, err := parseIDParam(r, "driveID")
|
||||
if err != nil {
|
||||
errorcode.RenderError(w, r, err)
|
||||
return
|
||||
}
|
||||
if chi.URLParam(r, "specialName") != RecycleBinSpecialFolderName {
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "unknown special folder")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -121,19 +131,6 @@ func (g Graph) listRecycleChildren(w http.ResponseWriter, r *http.Request, drive
|
||||
return files, true
|
||||
}
|
||||
|
||||
func parseSpecialParams(w http.ResponseWriter, r *http.Request) (storageprovider.ResourceId, bool) {
|
||||
driveID, err := parseIDParam(r, "driveID")
|
||||
if err != nil {
|
||||
errorcode.RenderError(w, r, err)
|
||||
return storageprovider.ResourceId{}, false
|
||||
}
|
||||
if chi.URLParam(r, "specialName") != RecycleBinSpecialFolderName {
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "unknown special folder")
|
||||
return storageprovider.ResourceId{}, false
|
||||
}
|
||||
return driveID, true
|
||||
}
|
||||
|
||||
// specialFolderKey returns the recycle key addressed by the colon path form, "" for the trash root
|
||||
func specialFolderKey(r *http.Request) string {
|
||||
p, _ := graphm.SpecialFolderPath(r.Context())
|
||||
|
||||
@@ -188,8 +188,13 @@ func (g Graph) PermanentDeleteDriveItem(w http.ResponseWriter, r *http.Request)
|
||||
func (g Graph) DeleteDriveSpecialItem(w http.ResponseWriter, r *http.Request) {
|
||||
g.logger.Debug().Msg("Calling DeleteDriveSpecialItem")
|
||||
|
||||
driveID, ok := parseSpecialParams(w, r)
|
||||
if !ok {
|
||||
driveID, err := parseIDParam(r, "driveID")
|
||||
if err != nil {
|
||||
errorcode.RenderError(w, r, err)
|
||||
return
|
||||
}
|
||||
if chi.URLParam(r, "specialName") != RecycleBinSpecialFolderName {
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "unknown special folder")
|
||||
return
|
||||
}
|
||||
itemID, ok := parseTrashItemID(w, r)
|
||||
@@ -205,8 +210,13 @@ func (g Graph) DeleteDriveSpecialItem(w http.ResponseWriter, r *http.Request) {
|
||||
func (g Graph) EmptyDriveSpecial(w http.ResponseWriter, r *http.Request) {
|
||||
g.logger.Debug().Msg("Calling EmptyDriveSpecial")
|
||||
|
||||
driveID, ok := parseSpecialParams(w, r)
|
||||
if !ok {
|
||||
driveID, err := parseIDParam(r, "driveID")
|
||||
if err != nil {
|
||||
errorcode.RenderError(w, r, err)
|
||||
return
|
||||
}
|
||||
if chi.URLParam(r, "specialName") != RecycleBinSpecialFolderName {
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "unknown special folder")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user