Fix bug #85 - Do not broadcast unknown commands, but allow for commands to be broadcasted if they are double escaped with ++ or !!.

This commit is contained in:
Jan Vidar Krey 2009-10-06 18:02:37 +02:00
parent 40fc09a7ef
commit f50b40fb92
2 changed files with 18 additions and 4 deletions

View File

@ -490,7 +490,7 @@ int command_dipatcher(struct hub_info* hub, struct hub_user* user, const char* m
/* Parse and validate the command */ /* Parse and validate the command */
struct hub_command* cmd = command_create(message); struct hub_command* cmd = command_create(message);
if (!cmd) return 1; if (!cmd) return 0;
for (n = 0; command_handlers[n].prefix; n++) for (n = 0; command_handlers[n].prefix; n++)
{ {
@ -524,7 +524,7 @@ int command_dipatcher(struct hub_info* hub, struct hub_user* user, const char* m
command_not_found(hub, user, cmd); command_not_found(hub, user, cmd);
command_destroy(cmd); command_destroy(cmd);
return 1; return 0;
} }
static struct commands_handler command_handlers[] = { static struct commands_handler command_handlers[] = {

View File

@ -183,9 +183,23 @@ int hub_handle_chat_message(struct hub_info* hub, struct hub_user* u, struct adc
int ret = 0; int ret = 0;
int relay = 1; int relay = 1;
if (message[0] == '!' || message[0] == '+') if ((cmd->cache[0] == 'B') && (message[0] == '!' || message[0] == '+'))
{ {
relay = command_dipatcher(hub, u, message); /*
* A message such as "++message" is handled as "+message", by removing the first character.
* The first character is removed by memmoving the string one byte to the left.
*/
if (message[1] == message[0])
{
relay = 1;
int offset = adc_msg_get_arg_offset(cmd);
memmove(cmd->cache+offset+1, cmd->cache+offset+2, cmd->length - offset);
cmd->length--;
}
else
{
relay = command_dipatcher(hub, u, message);
}
} }
if (hub->config->chat_is_privileged && !user_is_protected(u) && (cmd->cache[0] == 'B' || cmd->cache[0] == 'F')) if (hub->config->chat_is_privileged && !user_is_protected(u) && (cmd->cache[0] == 'B' || cmd->cache[0] == 'F'))