X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_operchans.cpp;h=8f600392302803f6be6ee046014bd03376177425;hb=5a2af6ded883d71c6c4c9f1497cca1721f8b0742;hp=8484d7dcc25cc658362d4d63768b5db0330a1b4e;hpb=e59cb85871f75b7603c63c6cd274d57536cf6794;p=user%2Fhenk%2Fcode%2Finspircd.git 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; }