diff options
-rw-r--r-- | src/modules/m_operchans.cpp | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp index 8484d7dcc..8f6003923 100644 --- a/src/modules/m_operchans.cpp +++ b/src/modules/m_operchans.cpp @@ -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; } |