From 946e90922e6753400934bad9d53fda27c73210f1 Mon Sep 17 00:00:00 2001 From: Jesse Geens Date: Fri, 29 Aug 2025 10:36:02 +0200 Subject: [PATCH] Make COPY work in public links in spaces --- changelog/unreleased/fix-copy-pl-spaces.md | 3 +++ internal/http/services/owncloud/ocdav/copy.go | 2 +- internal/http/services/owncloud/ocdav/ocdav.go | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/fix-copy-pl-spaces.md diff --git a/changelog/unreleased/fix-copy-pl-spaces.md b/changelog/unreleased/fix-copy-pl-spaces.md new file mode 100644 index 00000000000..79be579c152 --- /dev/null +++ b/changelog/unreleased/fix-copy-pl-spaces.md @@ -0,0 +1,3 @@ +Bugfix: Make COPY work in public links in spaces + +https://github.com/cs3org/reva/pull/5284/files \ No newline at end of file diff --git a/internal/http/services/owncloud/ocdav/copy.go b/internal/http/services/owncloud/ocdav/copy.go index f95b4dc0e63..c56fc9b4515 100644 --- a/internal/http/services/owncloud/ocdav/copy.go +++ b/internal/http/services/owncloud/ocdav/copy.go @@ -83,7 +83,7 @@ func (s *svc) handlePathCopy(w http.ResponseWriter, r *http.Request, ns string) } // For the destination, we still need to handle this ourselves - if s.c.SpacesEnabled { + if s.c.SpacesEnabled && ns != "/public" { dstSpaceID, dstRelPath := router.ShiftPath(dst) _, spaceRoot, ok := spaces.DecodeStorageSpaceID(dstSpaceID) if !ok { diff --git a/internal/http/services/owncloud/ocdav/ocdav.go b/internal/http/services/owncloud/ocdav/ocdav.go index b001df5419f..c132004524a 100644 --- a/internal/http/services/owncloud/ocdav/ocdav.go +++ b/internal/http/services/owncloud/ocdav/ocdav.go @@ -369,7 +369,9 @@ func extractDestination(r *http.Request) (string, error) { baseURI := r.Context().Value(ctxKeyBaseURI).(string) // TODO check if path is on same storage, return 502 on problems, see https://tools.ietf.org/html/rfc4918#section-9.9.4 // Strip the base URI from the destination. The destination might contain redirection prefixes which need to be handled - return strings.TrimPrefix(dstURL.Path, baseURI), nil + destination := strings.TrimPrefix(dstURL.Path, baseURI) + return destination, nil + } // replaceAllStringSubmatchFunc is taken from 'Go: Replace String with Regular Expression Callback'