mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 05:42:46 +00:00
reject invalid UTF-8 (#1472)
* reject invalid UTF-8 Signed-off-by: Jonas Fentker <jonas@fentker.eu> * update sytest-whitelist Signed-off-by: Jonas Fentker <jonas@fentker.eu> Co-authored-by: Kegsay <kegan@matrix.org>
This commit is contained in:
parent
f3e8ae01ef
commit
c4c8bfd027
4 changed files with 29 additions and 10 deletions
|
@ -15,11 +15,11 @@
|
|||
package routing
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/clientapi/auth"
|
||||
"github.com/matrix-org/dendrite/clientapi/httputil"
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/userapi/api"
|
||||
userapi "github.com/matrix-org/dendrite/userapi/api"
|
||||
|
@ -121,9 +121,8 @@ func UpdateDeviceByID(
|
|||
|
||||
payload := deviceUpdateJSON{}
|
||||
|
||||
if err := json.NewDecoder(req.Body).Decode(&payload); err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("json.NewDecoder.Decode failed")
|
||||
return jsonerror.InternalServerError()
|
||||
if resErr := httputil.UnmarshalJSONRequest(req, &payload); resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
|
||||
var performRes api.PerformDeviceUpdateResponse
|
||||
|
@ -211,9 +210,8 @@ func DeleteDevices(
|
|||
ctx := req.Context()
|
||||
payload := devicesDeleteJSON{}
|
||||
|
||||
if err := json.NewDecoder(req.Body).Decode(&payload); err != nil {
|
||||
util.GetLogger(ctx).WithError(err).Error("json.NewDecoder.Decode failed")
|
||||
return jsonerror.InternalServerError()
|
||||
if resErr := httputil.UnmarshalJSONRequest(req, &payload); resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
|
||||
defer req.Body.Close() // nolint: errcheck
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
||||
"github.com/matrix-org/dendrite/clientapi/api"
|
||||
"github.com/matrix-org/dendrite/clientapi/auth"
|
||||
clientutil "github.com/matrix-org/dendrite/clientapi/httputil"
|
||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||
"github.com/matrix-org/dendrite/clientapi/producers"
|
||||
eduServerAPI "github.com/matrix-org/dendrite/eduserver/api"
|
||||
|
@ -659,8 +660,9 @@ func Setup(
|
|||
SearchString string `json:"search_term"`
|
||||
Limit int `json:"limit"`
|
||||
}{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&postContent); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
|
||||
if resErr := clientutil.UnmarshalJSONRequest(req, &postContent); resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
return *SearchUserDirectory(
|
||||
req.Context(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue