From c586c14b9f278a4e13389dc4bbbe7be09be42543 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Wed, 22 Dec 2021 09:25:59 +0100 Subject: [PATCH] Fix ~T / ~text ban not working (was not censoring or blocking) --- src/modules/extbans/textban.c | 39 ++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/modules/extbans/textban.c b/src/modules/extbans/textban.c index 580824ce1..cc241f5a5 100644 --- a/src/modules/extbans/textban.c +++ b/src/modules/extbans/textban.c @@ -393,21 +393,29 @@ int textban_can_send_to_channel(Client *client, Channel *channel, Membership *lp /* Now we have to manually walk the banlist and check if things match */ for (ban = channel->banlist; ban; ban=ban->next) { - if (!strncmp(ban->banstr, "~T:", 3)) + char *banstr = ban->banstr; + + /* Pretend time does not exist... */ + if (!strncmp(banstr, "~t:", 3)) { - /* ~T ban */ - if (textban_check_ban(client, channel, ban->banstr, msg, errmsg)) + banstr = strchr(banstr+3, ':'); + if (!banstr) + continue; + banstr++; + } + else if (!strncmp(banstr, "~time:", 6)) + { + banstr = strchr(banstr+6, ':'); + if (!banstr) + continue; + banstr++; + } + + if (!strncmp(banstr, "~T:", 3) || !strncmp(banstr, "~text:", 6)) + { + /* text ban */ + if (textban_check_ban(client, channel, banstr, msg, errmsg)) return HOOK_DENY; - } else - if (!strncmp(ban->banstr, "~t:", 3)) - { - /* Stacked ~t:xx:~T ban (timed text ban) */ - char *p = strchr(ban->banstr+3, ':'); - if (p && !strncmp(p+1, "~T:", 3)) - { - if (textban_check_ban(client, channel, p+1, msg, errmsg)) - return HOOK_DENY; - } } } @@ -439,7 +447,10 @@ int textban_check_ban(Client *client, Channel *channel, const char *ban, const c #endif strlcpy(filtered, StripControlCodes(*msg), sizeof(filtered)); - p = ban + 3; + p = strchr(ban, ':'); + if (!p) + return 0; /* "impossible" */ + p++; #ifdef UHOSTFEATURE /* First.. deal with userhost... */ strcpy(buf, p);