about summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-08-13 09:33:16 -0400
committerJune McEnroe <june@causal.agency>2020-08-13 09:33:16 -0400
commit6f1cb708f0105027f0b2948130e71e0cf0995c89 (patch)
treef9b30bc976ea2ff55be68e98ae93e624adf87845 /client.c
parentAdd Additional Components section to README (diff)
downloadpounce-6f1cb708f0105027f0b2948130e71e0cf0995c89.tar.gz
pounce-6f1cb708f0105027f0b2948130e71e0cf0995c89.zip
Fix unintended interception of NICK after registration
Another bug caused by trying to support broken clients. I'm annoyed.
Diffstat (limited to '')
-rw-r--r--client.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/client.c b/client.c
index d0df0aa..06efeb8 100644
--- a/client.c
+++ b/client.c
@@ -318,20 +318,21 @@ static void handlePalaver(struct Client *client, struct Message *msg) {
 }
 
 static const struct {
+	bool intercept;
+	bool need;
 	const char *cmd;
 	Handler *fn;
-	bool need;
 } Handlers[] = {
-	{ "AUTHENTICATE", handleAuthenticate, false },
-	{ "CAP", handleCap, false },
-	{ "NICK", handleNick, false },
-	{ "NOTICE", handlePrivmsg, true },
-	{ "PALAVER", handlePalaver, false },
-	{ "PASS", handlePass, false },
-	{ "PRIVMSG", handlePrivmsg, true },
-	{ "QUIT", handleQuit, true },
-	{ "TAGMSG", handleTagmsg, true },
-	{ "USER", handleUser, false },
+	{ false, false, "AUTHENTICATE", handleAuthenticate },
+	{ false, false, "NICK", handleNick },
+	{ false, false, "PASS", handlePass },
+	{ false, false, "USER", handleUser },
+	{ true, false, "CAP", handleCap },
+	{ true, false, "PALAVER", handlePalaver },
+	{ true, true, "NOTICE", handlePrivmsg },
+	{ true, true, "PRIVMSG", handlePrivmsg },
+	{ true, true, "QUIT", handleQuit },
+	{ true, true, "TAGMSG", handleTagmsg },
 };
 
 static void clientParse(struct Client *client, char *line) {
@@ -355,6 +356,7 @@ static bool intercept(const char *line, size_t len) {
 		line = sp;
 	}
 	for (size_t i = 0; i < ARRAY_LEN(Handlers); ++i) {
+		if (!Handlers[i].intercept) continue;
 		size_t n = strlen(Handlers[i].cmd);
 		if (len < n) continue;
 		if (memcmp(line, Handlers[i].cmd, n)) continue;