Skip to content

Commit

Permalink
check status codes
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Nov 4, 2020
1 parent 4a28e84 commit 54a58fa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net/http"
"path"

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp/router"
Expand Down Expand Up @@ -106,6 +107,19 @@ func (s *svc) adjustResourcePathInURL(w http.ResponseWriter, r *http.Request) bo
w.WriteHeader(http.StatusNotFound)
return false
}
if pathRes.Status.Code != rpc.Code_CODE_OK {
switch pathRes.Status.Code {
case rpc.Code_CODE_NOT_FOUND:
w.WriteHeader(http.StatusNotFound)
return false
case rpc.Code_CODE_PERMISSION_DENIED:
w.WriteHeader(http.StatusForbidden)
return false
default:
w.WriteHeader(http.StatusInternalServerError)
return false
}
}
if path.Base(r.URL.Path) != path.Base(pathRes.Path) {
w.WriteHeader(http.StatusNotFound)
return false
Expand Down Expand Up @@ -165,6 +179,19 @@ func (s *svc) handlePropfindOnToken(w http.ResponseWriter, r *http.Request, ns s
w.WriteHeader(http.StatusNotFound)
return
}
if pathRes.Status.Code != rpc.Code_CODE_OK {
switch pathRes.Status.Code {
case rpc.Code_CODE_NOT_FOUND:
w.WriteHeader(http.StatusNotFound)
return
case rpc.Code_CODE_PERMISSION_DENIED:
w.WriteHeader(http.StatusForbidden)
return
default:
w.WriteHeader(http.StatusInternalServerError)
return
}
}

infos := []*provider.ResourceInfo{}

Expand Down

0 comments on commit 54a58fa

Please sign in to comment.