From 0bb42d2c667efba601538a76d8117a6ff87fcd43 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Tue, 3 May 2022 15:35:56 +0200 Subject: [PATCH 1/2] fix trash-bin propfind responses --- changelog/unreleased/fix-trashbin-propfind.md | 6 ++++++ internal/http/services/owncloud/ocdav/trashbin.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/fix-trashbin-propfind.md diff --git a/changelog/unreleased/fix-trashbin-propfind.md b/changelog/unreleased/fix-trashbin-propfind.md new file mode 100644 index 0000000000..783e093df8 --- /dev/null +++ b/changelog/unreleased/fix-trashbin-propfind.md @@ -0,0 +1,6 @@ +Bugfix: Fix trash-bin propfind responses + +Fixed the href of the root element in trash-bin propfind responses. + +https://github.com/owncloud/ocis/issues/1846 +https://github.com/cs3org/reva/pull/2821 diff --git a/internal/http/services/owncloud/ocdav/trashbin.go b/internal/http/services/owncloud/ocdav/trashbin.go index 6042ebbdb0..3a74f555cb 100644 --- a/internal/http/services/owncloud/ocdav/trashbin.go +++ b/internal/http/services/owncloud/ocdav/trashbin.go @@ -295,7 +295,7 @@ func (h *TrashbinHandler) formatTrashPropfind(ctx context.Context, s *svc, space responses := make([]*propfind.ResponseXML, 0, len(items)+1) // add trashbin dir . entry responses = append(responses, &propfind.ResponseXML{ - Href: net.EncodePath(ctx.Value(net.CtxKeyBaseURI).(string) + "/"), // url encode response.Href TODO + Href: net.EncodePath(path.Join(ctx.Value(net.CtxKeyBaseURI).(string), refBase) + "/"), // url encode response.Href TODO Propstat: []propfind.PropstatXML{ { Status: "HTTP/1.1 200 OK", From 5bcbddc7151e65004d9ce08a07ec1b633b04b809 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Wed, 4 May 2022 14:50:09 +0200 Subject: [PATCH 2/2] fix root item href in trash-bin propfind responses --- internal/http/services/owncloud/ocdav/trashbin.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/http/services/owncloud/ocdav/trashbin.go b/internal/http/services/owncloud/ocdav/trashbin.go index 3a74f555cb..cb6ef53008 100644 --- a/internal/http/services/owncloud/ocdav/trashbin.go +++ b/internal/http/services/owncloud/ocdav/trashbin.go @@ -191,7 +191,8 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s } if depth == net.DepthZero { - propRes, err := h.formatTrashPropfind(ctx, s, ref.ResourceId.StorageId, refBase, nil, nil) + rootHref := path.Join(refBase, key, itemPath) + propRes, err := h.formatTrashPropfind(ctx, s, ref.ResourceId.StorageId, refBase, rootHref, nil, nil) if err != nil { sublog.Error().Err(err).Msg("error formatting propfind") w.WriteHeader(http.StatusInternalServerError) @@ -275,7 +276,8 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s } } - propRes, err := h.formatTrashPropfind(ctx, s, ref.ResourceId.StorageId, refBase, &pf, items) + rootHref := path.Join(refBase, key, itemPath) + propRes, err := h.formatTrashPropfind(ctx, s, ref.ResourceId.StorageId, refBase, rootHref, &pf, items) if err != nil { sublog.Error().Err(err).Msg("error formatting propfind") w.WriteHeader(http.StatusInternalServerError) @@ -291,11 +293,11 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s } } -func (h *TrashbinHandler) formatTrashPropfind(ctx context.Context, s *svc, spaceID, refBase string, pf *propfind.XML, items []*provider.RecycleItem) ([]byte, error) { +func (h *TrashbinHandler) formatTrashPropfind(ctx context.Context, s *svc, spaceID, refBase, rootHref string, pf *propfind.XML, items []*provider.RecycleItem) ([]byte, error) { responses := make([]*propfind.ResponseXML, 0, len(items)+1) // add trashbin dir . entry responses = append(responses, &propfind.ResponseXML{ - Href: net.EncodePath(path.Join(ctx.Value(net.CtxKeyBaseURI).(string), refBase) + "/"), // url encode response.Href TODO + Href: net.EncodePath(path.Join(ctx.Value(net.CtxKeyBaseURI).(string), rootHref) + "/"), // url encode response.Href TODO Propstat: []propfind.PropstatXML{ { Status: "HTTP/1.1 200 OK",