]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Replace spaces with underscores when checking for class bans.
authorSadie Powell <sadie@witchery.services>
Fri, 25 Dec 2020 03:42:11 +0000 (03:42 +0000)
committerSadie Powell <sadie@witchery.services>
Fri, 25 Dec 2020 03:42:22 +0000 (03:42 +0000)
src/modules/m_classban.cpp

index 89cbf0efebc48df808118689ed6418a0def9abb8..b2cbb1e597d75cc2054a7698ad828c722710bb8f 100644 (file)
 
 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;
        }