Crash using VTX Client #284

* Fix try/catch around JSON.parse()
* Ensure we don't try to replace on null/undefined no matter what
This commit is contained in:
Bryan Ashby 2020-06-01 19:22:15 -06:00
parent 10ec5d4271
commit 5b20c3ec38
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
1 changed files with 3 additions and 4 deletions

View File

@ -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');