mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-08 18:16:59 +00:00
Return the correct error codes for v6 invite JSON violations (#1440)
* Return the correct error codes for v6 invite JSON violations * Update sytest-whitelist
This commit is contained in:
parent
3013ade84f
commit
6fbf89a166
@ -39,7 +39,15 @@ func InviteV2(
|
||||
keys gomatrixserverlib.JSONVerifier,
|
||||
) util.JSONResponse {
|
||||
inviteReq := gomatrixserverlib.InviteV2Request{}
|
||||
if err := json.Unmarshal(request.Content(), &inviteReq); err != nil {
|
||||
err := json.Unmarshal(request.Content(), &inviteReq)
|
||||
switch err.(type) {
|
||||
case gomatrixserverlib.BadJSONError:
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON(err.Error()),
|
||||
}
|
||||
case nil:
|
||||
default:
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.NotJSON("The request body could not be decoded into an invite request. " + err.Error()),
|
||||
@ -63,10 +71,17 @@ func InviteV1(
|
||||
roomVer := gomatrixserverlib.RoomVersionV1
|
||||
body := request.Content()
|
||||
event, err := gomatrixserverlib.NewEventFromTrustedJSON(body, false, roomVer)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case gomatrixserverlib.BadJSONError:
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.NotJSON("The request body could not be decoded into an invite v1 request: " + err.Error()),
|
||||
JSON: jsonerror.BadJSON(err.Error()),
|
||||
}
|
||||
case nil:
|
||||
default:
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.NotJSON("The request body could not be decoded into an invite v1 request. " + err.Error()),
|
||||
}
|
||||
}
|
||||
var strippedState []gomatrixserverlib.InviteV2StrippedState
|
||||
|
@ -138,7 +138,14 @@ func SendLeave(
|
||||
|
||||
// Decode the event JSON from the request.
|
||||
event, err := gomatrixserverlib.NewEventFromUntrustedJSON(request.Content(), verRes.RoomVersion)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case gomatrixserverlib.BadJSONError:
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON(err.Error()),
|
||||
}
|
||||
case nil:
|
||||
default:
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()),
|
||||
|
@ -478,3 +478,5 @@ Inbound federation accepts a second soft-failed event
|
||||
Federation key API can act as a notary server via a POST request
|
||||
Federation key API can act as a notary server via a GET request
|
||||
Inbound /make_join rejects attempts to join rooms where all users have left
|
||||
Inbound federation rejects invites which include invalid JSON for room version 6
|
||||
Inbound federation rejects invite rejections which include invalid JSON for room version 6
|
||||
|
Loading…
Reference in New Issue
Block a user