From 54511a6ceaf8889441fdb0ef4482c9ca2e47f212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bartelme=C3=9F?= Date: Tue, 22 May 2012 09:27:08 +0200 Subject: [PATCH] fix #722 by better argument checking in PadMessageHandler.js --- node/handler/PadMessageHandler.js | 39 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/node/handler/PadMessageHandler.js b/node/handler/PadMessageHandler.js index 48f0aa988..135b4b631 100644 --- a/node/handler/PadMessageHandler.js +++ b/node/handler/PadMessageHandler.js @@ -170,26 +170,25 @@ exports.handleMessage = function(client, message) { handleClientReady(client, message); } - else if(message.type == "COLLABROOM" && - message.data.type == "USER_CHANGES") - { - handleUserChanges(client, message); - } - else if(message.type == "COLLABROOM" && - message.data.type == "USERINFO_UPDATE") - { - handleUserInfoUpdate(client, message); - } - else if(message.type == "COLLABROOM" && - message.data.type == "CHAT_MESSAGE") - { - handleChatMessage(client, message); - } - else if(message.type == "COLLABROOM" && - message.data.type == "CLIENT_MESSAGE" && - message.data.payload.type == "suggestUserName") - { - handleSuggestUserName(client, message); + else if(message.type == "COLLABROOM" && typeof message.data == 'object'){ + if (message.data.type == "USER_CHANGES") + { + handleUserChanges(client, message); + } + else if (message.data.type == "USERINFO_UPDATE") + { + handleUserInfoUpdate(client, message); + } + else if(message.data.type == "CHAT_MESSAGE") + { + handleChatMessage(client, message); + } + else if(message.data.type == "CLIENT_MESSAGE" && + typeof message.data.payload == 'object' && + message.data.payload.type == "suggestUserName") + { + handleSuggestUserName(client, message); + } } //if the message type is unknown, throw an exception else