From 7c9b10c6b5a1ed9bbc1cbd95a7f3a88a0bc6ffea Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Mon, 15 Nov 2021 14:01:20 +0100 Subject: [PATCH] Trim file paths for non-global path cases --- internal/http/services/owncloud/ocdav/report.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/http/services/owncloud/ocdav/report.go b/internal/http/services/owncloud/ocdav/report.go index c3fd72a2980..c7d3200b9f1 100644 --- a/internal/http/services/owncloud/ocdav/report.go +++ b/internal/http/services/owncloud/ocdav/report.go @@ -22,6 +22,7 @@ import ( "encoding/xml" "io" "net/http" + "path/filepath" rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" @@ -105,6 +106,19 @@ func (s *svc) doFilterFiles(w http.ResponseWriter, r *http.Request, ff *reportFi log.Error().Interface("stat_response", statRes).Msg("error getting resource info") continue } + + // If global URLs are not supported, return only the file path + if s.c.WebdavNamespace != "" { + // The paths we receive have the format /user// + // We only want the `` part. Thus we remove the /user// part. + rel, err := filepath.Rel(namespace, statRes.Info.Path) + if err != nil { + log.Error().Err(err).Msg("path doesn't have the expected format") + continue + } + statRes.Info.Path = filepath.Join("/", rel) + } + infos = append(infos, statRes.Info) }