]> jfr.im git - irc/hexchat/hexchat.git/commitdiff
Improve CTCP notice handling
authorPatrick Griffis <redacted>
Sat, 7 Oct 2017 21:31:53 +0000 (17:31 -0400)
committerPatrick Griffis <redacted>
Sat, 7 Oct 2017 21:31:53 +0000 (17:31 -0400)
Cutting off all text after \001 can result in users hiding text
so lets only bother handling it if it is a valid CTCP message
(starting and ending with \001).

src/common/inbound.c

index 6931bdc141570fbc287c0ed9ae4f358308ded794..8d299ed89a5fc74e0472c926b89ddbe2b07d67f8 100644 (file)
@@ -932,7 +932,7 @@ void
 inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id,
                                         const message_tags_data *tags_data)
 {
-       char *po,*ptr=to;
+       char *ptr = to;
        session *sess = 0;
        int server_notice = FALSE;
 
@@ -1005,18 +1005,21 @@ inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id,
                }
        }
 
-       if (msg[0] == 1)
+       if (msg[0] == '\001')
        {
+               size_t len;
+
                msg++;
                if (!strncmp (msg, "PING", 4))
                {
                        inbound_ping_reply (sess, msg + 5, nick, tags_data);
                        return;
                }
+
+               len = strlen(msg);
+               if (msg[len - 1] == '\001')
+                       msg[len - 1] = '\000';
        }
-       po = strchr (msg, '\001');
-       if (po)
-               po[0] = 0;
 
        if (server_notice)
                EMIT_SIGNAL_TIMESTAMP (XP_TE_SERVNOTICE, sess, msg, nick, NULL, NULL, 0,