Skip to content

Commit

Permalink
Fix home storage redirect for remote.php/dav/files (#1342)
Browse files Browse the repository at this point in the history
  • Loading branch information
refs authored Nov 27, 2020
1 parent 3e50f7b commit e6a6212
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
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

0 comments on commit e6a6212

Please sign in to comment.