From dcd6fa89bc75da4c05031b5af4e44304e3ad6980 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 19 Dec 2022 11:29:55 +0000 Subject: Fix parsing extbans in banredirect and timedbans. --- src/modules/m_banredirect.cpp | 8 ++++++-- src/modules/m_timedbans.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 83ad230e8..f47aacbc8 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -31,6 +31,7 @@ #include "inspircd.h" #include "listmode.h" +#include "modules/extban.h" /* Originally written by Om, January 2009 */ @@ -55,11 +56,13 @@ class BanRedirect final { public: ChanModeReference banmode; + ExtBan::ManagerRef extbanmgr; SimpleExtItem redirectlist; BanRedirect(Module* parent) : ModeWatcher(parent, "ban", MODETYPE_CHANNEL) , banmode(parent, "ban") + , extbanmgr(parent) , redirectlist(parent, "banredirect", ExtensionType::CHANNEL) { } @@ -81,8 +84,9 @@ public: enum { NICK, IDENT, HOST, CHAN } current = NICK; std::string::iterator start_pos = change.param.begin(); - if (change.param.length() >= 2 && change.param[1] == ':') - return true; + std::string unused = change.param; + if (extbanmgr && extbanmgr->Canonicalize(unused)) + return true; // Skip extbans. if (change.param.find('#') == std::string::npos) return true; diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index b5348c84b..6dd1d9f79 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -32,6 +32,7 @@ #include "inspircd.h" #include "listmode.h" +#include "modules/extban.h" #include "numerichelper.h" // Holds a timed ban @@ -50,7 +51,9 @@ timedbans TimedBanList; class CommandTban final : public Command { +private: ChanModeReference banmode; + ExtBan::ManagerRef extbanmgr; bool IsBanSet(Channel* chan, const std::string& mask) { @@ -77,6 +80,7 @@ public: CommandTban(Module* Creator) : Command(Creator, "TBAN", 3) , banmode(Creator, "ban") + , extbanmgr(Creator) { syntax = { " " }; } @@ -107,9 +111,8 @@ public: unsigned long expire = duration + ServerInstance->Time(); std::string mask = parameters[2]; - bool isextban = ((mask.size() > 2) && (mask[1] == ':')); - if (!isextban && !InspIRCd::IsValidMask(mask)) - mask.append("!*@*"); + if (!extbanmgr || !extbanmgr->Canonicalize(mask)) + ModeParser::CleanMask(mask); if (IsBanSet(channel, mask)) { -- cgit v1.3.1-10-gc9f91