From 3a6ff15c475069f707d1fd81aee0c101f73272c8 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 11 Nov 2019 00:16:50 -0500 Subject: Filter userhost-in-names I really want to be writing tests for these functions... --- client.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'client.c') diff --git a/client.c b/client.c index 201566e..dec0041 100644 --- a/client.c +++ b/client.c @@ -318,12 +318,29 @@ static const char *filterInviteNotify(const char *line) { return (wordcmp(line, 2, stateNick()) ? NULL : line); } +static const char *filterUserhostInNames(const char *line) { + if (wordcmp(line, 1, "353")) return line; + static char buf[512]; + if (strlen(line) >= sizeof(buf)) return NULL; + char *ptr = buf; + while (*line) { + size_t len = strcspn(line, "!"); + memcpy(ptr, line, len); + ptr += len; + line += len; + line += strcspn(line, " "); + } + *ptr = '\0'; + return buf; +} + static Filter *Filters[] = { [CapAccountNotifyBit] = filterAccountNotify, [CapAwayNotifyBit] = filterAwayNotify, [CapChghostBit] = filterChghost, [CapExtendedJoinBit] = filterExtendedJoin, [CapInviteNotifyBit] = filterInviteNotify, + [CapUserhostInNamesBit] = filterUserhostInNames, }; void clientConsume(struct Client *client) { -- cgit 1.4.1