Permalink
Browse files

fix #722 by better argument checking in PadMessageHandler.js

  • Loading branch information...
1 parent 185a3bf commit 06c36f3023404f0950e03db028bc9887a24ecdff @fourplusone fourplusone committed May 22, 2012
Showing with 19 additions and 25 deletions.
  1. +19 −25 src/node/handler/PadMessageHandler.js
View
44 src/node/handler/PadMessageHandler.js
@@ -177,31 +177,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 == "SAVE_REVISION")
- {
- handleSaveRevisionMessage(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

0 comments on commit 06c36f3

Please sign in to comment.