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 home storage redirect for remote.php/dav/files #1342

Merged
merged 2 commits into from
Nov 27, 2020
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
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-files-home-redirect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Dav endpoint routing to home storage when request is remote.php/dav/files

There was a regression in which we were not routing correctly to the right storage depending on the url.

https://github.com/cs3org/reva/pull/1342
35 changes: 21 additions & 14 deletions internal/http/services/owncloud/ocdav/dav.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,30 @@ func (h *DavHandler) Handler(s *svc) http.Handler {
// https://github.com/owncloud/core/blob/18475dac812064b21dabcc50f25ef3ffe55691a5/tests/acceptance/features/apiWebdavOperations/propfind.feature
if r.URL.Path == "/files" {
log.Debug().Str("path", r.URL.Path).Msg("method not allowed")
w.WriteHeader(http.StatusMethodNotAllowed)
b, err := Marshal(exception{
code: SabredavMethodNotAllowed,
message: "Listing members of this collection is disabled",
})
if err != nil {
log.Error().Msgf("error marshaling xml response: %s", b)
w.WriteHeader(http.StatusInternalServerError)
return
contextUser, ok := ctxuser.ContextGetUser(ctx)
if ok {
r.URL.Path = path.Join(r.URL.Path, contextUser.Username)
}
_, err = w.Write(b)
if err != nil {
log.Error().Msgf("error writing xml response: %s", b)
w.WriteHeader(http.StatusInternalServerError)

if r.Header.Get("Depth") == "" {
w.WriteHeader(http.StatusMethodNotAllowed)
b, err := Marshal(exception{
code: SabredavMethodNotAllowed,
message: "Listing members of this collection is disabled",
})
if err != nil {
log.Error().Msgf("error marshaling xml response: %s", b)
w.WriteHeader(http.StatusInternalServerError)
return
}
_, err = w.Write(b)
if err != nil {
log.Error().Msgf("error writing xml response: %s", b)
w.WriteHeader(http.StatusInternalServerError)
return
}
return
}
return
}

var head string
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (s *svc) handlePropfind(w http.ResponseWriter, r *http.Request, ns string)
depth = "1"
}

// see https://tools.ietf.org/html/rfc4918#section-10.2
// see https://tools.ietf.org/html/rfc4918#section-9.1
if depth != "0" && depth != "1" && depth != "infinity" {
log.Error().Msgf("invalid Depth header value %s", depth)
w.WriteHeader(http.StatusBadRequest)
Expand Down