From 0464b094a6fa911204891a15a6b8af4cef0fa09b Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Wed, 6 Nov 2019 11:44:32 +0000
Subject: [PATCH] Fix softcrash if editing silly events

If you sent an event with a body of the empty json object, riot
would then softcrash when you pressed the up arrow because it
would try to treat a json object as a string and run split on it.
---
 src/utils/EventUtils.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/utils/EventUtils.js b/src/utils/EventUtils.js
index ffc47e2277..29af5ca9b5 100644
--- a/src/utils/EventUtils.js
+++ b/src/utils/EventUtils.js
@@ -52,6 +52,7 @@ export function canEditContent(mxEvent) {
     const content = mxEvent.getOriginalContent();
     const {msgtype} = content;
     return (msgtype === "m.text" || msgtype === "m.emote") &&
+        content.body && typeof content.body === 'string' &&
         mxEvent.getSender() === MatrixClientPeg.get().getUserId();
 }