diff options
author | Sadie Powell <sadie@witchery.services> | 2020-12-25 03:42:11 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2020-12-25 03:42:22 +0000 |
commit | 71ad7b2cd22ace30dae3506a39858c804e7f1895 (patch) | |
tree | 3512df454810680f3e0cc5d887f816484c4492c3 /src | |
parent | aa101e59e5bd08304728a015dfef0bf22101fc0c (diff) |
Replace spaces with underscores when checking for class bans.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_classban.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/modules/m_classban.cpp b/src/modules/m_classban.cpp index 89cbf0efe..b2cbb1e59 100644 --- a/src/modules/m_classban.cpp +++ b/src/modules/m_classban.cpp @@ -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; } |