Fix when /affiliate cmd doesn't get enough args (#557)

Added array bounds checking to /affiliate command parsing.

Maybe some user feedback when using the different commands would be
useful.
This commit is contained in:
Aearil 2019-04-29 14:24:29 +00:00 committed by fiaxh
parent 97c59cb8cd
commit f4778ef3e6

View file

@ -112,8 +112,12 @@ public class View : Box {
stream_interactor.get_module(MucManager.IDENTITY).kick(conversation.account, conversation.counterpart, token[1]); stream_interactor.get_module(MucManager.IDENTITY).kick(conversation.account, conversation.counterpart, token[1]);
return; return;
case "/affiliate": case "/affiliate":
if (token.length > 1) {
string[] user_role = token[1].split(" ", 2); string[] user_role = token[1].split(" ", 2);
if (user_role.length == 2) {
stream_interactor.get_module(MucManager.IDENTITY).change_affiliation(conversation.account, conversation.counterpart, user_role[0].strip(), user_role[1].strip()); stream_interactor.get_module(MucManager.IDENTITY).change_affiliation(conversation.account, conversation.counterpart, user_role[0].strip(), user_role[1].strip());
}
}
return; return;
case "/nick": case "/nick":
stream_interactor.get_module(MucManager.IDENTITY).change_nick(conversation.account, conversation.counterpart, token[1]); stream_interactor.get_module(MucManager.IDENTITY).change_nick(conversation.account, conversation.counterpart, token[1]);