From e42bab8c1d472b5c44acfa0d1a34af5fa1dc5235 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 28 Mar 2022 10:09:14 +0100 Subject: [PATCH] Use `httputil.UnmarshalJSON` as that should enforce UTF-8 correctness --- clientapi/routing/register.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 325895603..c9e03fed7 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -41,6 +41,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/auth" "github.com/matrix-org/dendrite/clientapi/auth/authtypes" + "github.com/matrix-org/dendrite/clientapi/httputil" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/clientapi/userutil" userapi "github.com/matrix-org/dendrite/userapi/api" @@ -549,7 +550,7 @@ func Register( r.InitialDisplayName = data.InitialDisplayName r.InhibitLogin = data.InhibitLogin } - if resErr := json.Unmarshal(reqBody, &r); resErr != nil { + if resErr := httputil.UnmarshalJSON(reqBody, &r); resErr != nil { return util.JSONResponse{ Code: http.StatusBadRequest, JSON: jsonerror.BadJSON("Request body contains invalid JSON"),