X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_classban.cpp;h=09815f2eafe1855bc9fcc3a8d2b9d3df3216d0eb;hb=HEAD;hp=89cbf0efebc48df808118689ed6418a0def9abb8;hpb=f3f2388a81b6463e1229fa5bf2b8c427440bf406;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_classban.cpp b/src/modules/m_classban.cpp index 89cbf0efe..09815f2ea 100644 --- a/src/modules/m_classban.cpp +++ b/src/modules/m_classban.cpp @@ -1,7 +1,7 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2020 Sadie Powell + * Copyright (C) 2020-2021 Sadie Powell * Copyright (C) 2016 Johanna A * * This file is part of InspIRCd. InspIRCd is free software: you can @@ -22,14 +22,28 @@ class ModuleClassBan : public Module { + private: + std::string space; + std::string underscore; + public: + ModuleClassBan() + : space(" ") + , underscore("_") + { + } + ModResult OnCheckBan(User* user, Channel* c, const std::string& mask) CXX11_OVERRIDE { LocalUser* localUser = IS_LOCAL(user); if ((localUser) && (mask.length() > 2) && (mask[0] == 'n') && (mask[1] == ':')) { - if (InspIRCd::Match(localUser->GetClass()->name, mask.substr(2))) + // Replace spaces with underscores as they're prohibited in mode parameters. + std::string classname(localUser->GetClass()->name); + stdalgo::string::replace_all(classname, space, underscore); + if (InspIRCd::Match(classname, mask.substr(2))) return MOD_RES_DENY; + } return MOD_RES_PASSTHRU; } @@ -41,7 +55,7 @@ class ModuleClassBan : public Module Version GetVersion() CXX11_OVERRIDE { - return Version("Adds the n: extended ban which check whether users are in a connect class matching the specified glob pattern.", VF_VENDOR | VF_OPTCOMMON); + return Version("Adds extended ban n: which check whether users are in a connect class matching the specified glob pattern.", VF_VENDOR | VF_OPTCOMMON); } };