Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix trash-bin propfind responses #2821

Merged
merged 2 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-trashbin-propfind.md
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions internal/http/services/owncloud/ocdav/trashbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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(ctx.Value(net.CtxKeyBaseURI).(string) + "/"), // 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",
Expand Down