commit 6062ad001db57c4e986b2c65001b2c5e38a39617
parent c1c5cdbbd03b91499796cae8a9a345e780daf8f5
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Thu, 14 Feb 2013 22:10:44 +0100
Fix wrong commands being accepted
Diffstat:
irctk.c | | | 28 | ++++++++++++++++++++++------ |
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/irctk.c b/irctk.c
@@ -1108,12 +1108,16 @@ int do_cmd_msg(irc_session_t *s, char *chan, char* line)
} else if ((arg = MATCH_CMD(line, "topic"))) {
rsl = irc_cmd_topic(s, chan, arg);
} else if ((arg = MATCH_CMD0(line, "quit"))) {
- char *rquit = NULL;
+ int ok = 1;
if (*arg == ' ') {
- rquit = arg + 1;
+ rsl = irc_cmd_quit(s, arg + 1);
+ } else if (!*arg || *arg == '\n') {
+ rsl = irc_cmd_quit(s, NULL);
+ } else {
+ info("Unrecognized command: %s", line);
+ ok = 0;
}
- rsl = irc_cmd_quit(s, rquit);
- if (!rsl)
+ if (!rsl && ok)
rsl = -1;
} else if ((arg = MATCH_CMD(line, "invite"))) {
char *inick = consume_word(&arg);
@@ -1128,10 +1132,22 @@ int do_cmd_msg(irc_session_t *s, char *chan, char* line)
rsl = irc_cmd_kick(s, knick, chan, arg);
free(knick);
} else if ((arg = MATCH_CMD0(line, "me"))) {
- rsl = do_me(s, chan, password, arg + (*arg?1:0));
+ if (*arg == ' ') {
+ rsl = do_me(s, chan, password, arg + 1);
+ } else if (!*arg || *arg == '\n') {
+ rsl = do_me(s, chan, password, arg);
+ } else {
+ info("Unrecognized command: %s", line);
+ }
} else if ((arg = MATCH_CMD0(line, "say"))) {
// just a way to escape messages starting by '/'
- rsl = do_say(s, chan, password, arg + (*arg?1:0));
+ if (*arg == ' ') {
+ rsl = do_say(s, chan, password, arg + 1);
+ } else if (!*arg || *arg == '\n') {
+ rsl = do_say(s, chan, password, arg);
+ } else {
+ info("Unrecognized command: %s", line);
+ }
} else if (line[1] == ' ') {
// another way, compatible with irssi: "/ /message"
rsl = do_say(s, chan, password, line + 2);