Skip to content

Commit

Permalink
Return an error if trying to invite a malformed user ID (matrix-org#2543
Browse files Browse the repository at this point in the history
)
  • Loading branch information
neilalexander authored Jun 29, 2022
1 parent 2086992 commit 2dea466
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion roomserver/internal/perform/perform_invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ func (r *Inviter) PerformInvite(
return nil, fmt.Errorf("failed to load RoomInfo: %w", err)
}

_, domain, _ := gomatrixserverlib.SplitID('@', targetUserID)
_, domain, err := gomatrixserverlib.SplitID('@', targetUserID)
if err != nil {
res.Error = &api.PerformError{
Code: api.PerformErrorBadRequest,
Msg: fmt.Sprintf("The user ID %q is invalid!", targetUserID),
}
return nil, nil
}
isTargetLocal := domain == r.Cfg.Matrix.ServerName
isOriginLocal := event.Origin() == r.Cfg.Matrix.ServerName

Expand Down

0 comments on commit 2dea466

Please sign in to comment.