From 5b20c3ec38ecfbf7bd673c26f96833e61f7783bb Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 1 Jun 2020 19:22:15 -0600 Subject: [PATCH] Crash using VTX Client #284 * Fix try/catch around JSON.parse() * Ensure we don't try to replace on null/undefined no matter what --- core/servers/chat/mrc_multiplexer.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/servers/chat/mrc_multiplexer.js b/core/servers/chat/mrc_multiplexer.js index 67ca9dc6..34991de7 100644 --- a/core/servers/chat/mrc_multiplexer.js +++ b/core/servers/chat/mrc_multiplexer.js @@ -249,11 +249,10 @@ exports.getModule = class MrcModule extends ServerModule { receiveFromClient(username, message) { try { message = JSON.parse(message); + this.sendToMrcServer(message.from_user, message.from_room, message.to_user, message.to_site, message.to_room, message.body); } catch (e) { Log.debug({ server : 'MRC', user : username, message : message }, 'Dodgy message received from client'); } - - this.sendToMrcServer(message.from_user, message.from_room, message.to_user, message.to_site, message.to_room, message.body); } /** @@ -264,11 +263,11 @@ exports.getModule = class MrcModule extends ServerModule { const line = [ fromUser, this.boardName, - sanitiseRoomName(fromRoom), + sanitiseRoomName(fromRoom || ''), sanitiseName(toUser || ''), sanitiseName(toSite || ''), sanitiseRoomName(toRoom || ''), - sanitiseMessage(messageBody) + sanitiseMessage(messageBody || '') ].join('~') + '~'; // Log.debug({ server : 'MRC', data : line }, 'Sending data');