use proper url path decode on the username

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2021-09-15 18:00:17 +02:00
parent cb3a5b811d
commit 50ab6596bb
2 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
Bugfix: use proper url path decode on the username
We now properly decode the username when reading it from a url parameter
https://github.com/owncloud/ocis/pull/2511

View File

@@ -2,6 +2,7 @@ package middleware
import (
"net/http"
"net/url"
revactx "github.com/cs3org/reva/pkg/ctx"
"github.com/go-chi/chi/v5"
@@ -44,6 +45,11 @@ func RequireSelfOrAdmin(opts ...Option) func(next http.Handler) http.Handler {
// check if self management permission is present in roles of the authenticated account
if opt.RoleManager.FindPermissionByID(r.Context(), roleIDs, accounts.SelfManagementPermissionID) != nil {
userid := chi.URLParam(r, "userid")
var err error
if userid, err = url.PathUnescape(userid); err != nil {
mustNotFail(render.Render(w, r, response.ErrRender(data.MetaBadRequest.StatusCode, "malformed username")))
}
if userid == "" || userid == u.Id.OpaqueId || userid == u.Username {
next.ServeHTTP(w, r)
return