From 42778e105caee9ee8a287b34b7d87d81331455dc Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Sat, 26 Jul 2025 14:26:56 -0400 Subject: [PATCH] restrict self-sent CTCP handling --- src/common/ctcp.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/common/ctcp.c b/src/common/ctcp.c index e56c367addd6ec25e333c00f0f1c2453446021dd..e47debed1285bc16dc7ff6525061f51e19e7feae 100644 --- a/src/common/ctcp.c +++ b/src/common/ctcp.c @@ -93,21 +93,9 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip, server *serv = sess->server; char outbuf[1024]; int ctcp_offset = 2; - - /* consider DCC to be different from other CTCPs */ - if (!g_ascii_strncasecmp (msg, "DCC", 3)) - { - /* but still let CTCP replies override it */ - if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) - { - if (!ignore_check (word[1], IG_DCC)) - handle_dcc (sess, nick, word, word_eol, tags_data); - } - return; - } - + /* consider ACTION to be different from other CTCPs. Check - ignore as if it was a PRIV/CHAN. */ + ignore as if it was a PRIV/CHAN. */ if (!g_ascii_strncasecmp (msg, "ACTION ", 7)) { if (is_channel (serv, to)) @@ -129,6 +117,23 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip, inbound_action (sess, to, nick, ip, msg + 7, FALSE, tags_data->identified, tags_data); return; } + + // ignore CTCPs if they're from us + // FIXME: this might fuck with plugins that care about CTCPs, especially custom ones + if (g_ascii_strcasecmp(to, serv->nick) != 0 && g_ascii_strcasecmp(nick, serv->nick) == 0) + return; + + /* consider DCC to be different from other CTCPs */ + if (!g_ascii_strncasecmp (msg, "DCC", 3)) + { + /* but still let CTCP replies override it */ + if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) + { + if (!ignore_check (word[1], IG_DCC)) + handle_dcc (sess, nick, word, word_eol, tags_data); + } + return; + } if (ignore_check (word[1], IG_CTCP)) return;