Fix extban O matching against oper types containing spaces.

Fixes #1684.
This commit is contained in:
Peter Powell 2019-07-31 21:49:47 +01:00
parent ef77989a9d
commit 7d17f0f275

View File

@ -40,9 +40,16 @@ class OperChans : public SimpleChannelModeHandler
class ModuleOperChans : public Module
{
private:
OperChans oc;
std::string space;
std::string underscore;
public:
ModuleOperChans() : oc(this)
ModuleOperChans()
: oc(this)
, space(" ")
, underscore("_")
{
}
@ -56,13 +63,27 @@ class ModuleOperChans : public Module
return MOD_RES_PASSTHRU;
}
ModResult OnCheckBan(User *user, Channel *c, const std::string& mask) CXX11_OVERRIDE
ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask) CXX11_OVERRIDE
{
if ((mask.length() > 2) && (mask[0] == 'O') && (mask[1] == ':'))
{
if (user->IsOper() && InspIRCd::Match(user->oper->name, mask.substr(2)))
return MOD_RES_DENY;
}
// Check whether the entry is an extban.
if (mask.length() <= 2 || mask[0] != 'O' || mask[1] != ':')
return MOD_RES_PASSTHRU;
// If the user is not an oper they can't match this.
if (!user->IsOper())
return MOD_RES_PASSTHRU;
// Check whether the oper's type matches the ban.
const std::string submask = mask.substr(2);
if (InspIRCd::Match(user->oper->name, submask))
return MOD_RES_DENY;
// If the oper's type contains spaces recheck with underscores.
std::string opername(user->oper->name);
stdalgo::string::replace_all(opername, space, underscore);
if (InspIRCd::Match(opername, submask))
return MOD_RES_DENY;
return MOD_RES_PASSTHRU;
}