]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_nationalchars.cpp
Fix the cloaking module on C++98 compilers.
[user/henk/code/inspircd.git] / src / modules / m_nationalchars.cpp
index 2b7e66a5038e2bcf9a6791331312de0cebbda0c0..3b9afd5bde1cc292dacc4f208f7e432adfa39207 100644 (file)
@@ -1,10 +1,16 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2009 Dennis Friis <peavey@inspircd.org>
- *   Copyright (C) 2009 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
+ *   Copyright (C) 2013, 2015, 2017, 2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012-2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2011 jackmcbarn <jackmcbarn@inspircd.org>
+ *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2009-2010 Craig Edwards <brain@inspircd.org>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
  *   Copyright (C) 2009 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2009 Dennis Friis <peavey@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -68,7 +74,7 @@ char utf8size(unsigned char * mb)
 /* Conditions added */
 bool lwbNickHandler::Call(const std::string& nick)
 {
-       if (nick.empty())
+       if (nick.empty() || isdigit(nick[0]))
                return false;
 
        const char* n = nick.c_str();
@@ -222,6 +228,7 @@ class ModuleNationalChars : public Module
        TR1NS::function<bool(const std::string&)> rememberer;
        bool forcequit;
        const unsigned char * lowermap_rememberer;
+       std::string casemapping_rememberer;
        unsigned char prev_map[256];
 
        template <typename T>
@@ -248,7 +255,9 @@ class ModuleNationalChars : public Module
 
  public:
        ModuleNationalChars()
-               : rememberer(ServerInstance->IsNick), lowermap_rememberer(national_case_insensitive_map)
+               : rememberer(ServerInstance->IsNick)
+               , lowermap_rememberer(national_case_insensitive_map)
+               , casemapping_rememberer(ServerInstance->Config->CaseMapping)
        {
                memcpy(prev_map, national_case_insensitive_map, sizeof(prev_map));
        }
@@ -265,7 +274,7 @@ class ModuleNationalChars : public Module
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("nationalchars");
                charset = tag->getString("file");
-               std::string casemapping = tag->getString("casemapping", FileSystem::GetFileName(charset));
+               std::string casemapping = tag->getString("casemapping", FileSystem::GetFileName(charset), 1);
                if (casemapping.find(' ') != std::string::npos)
                        throw ModuleException("<nationalchars:casemapping> must not contain any spaces!");
                ServerInstance->Config->CaseMapping = casemapping;
@@ -305,13 +314,16 @@ class ModuleNationalChars : public Module
        {
                ServerInstance->IsNick = rememberer;
                national_case_insensitive_map = lowermap_rememberer;
+               ServerInstance->Config->CaseMapping = casemapping_rememberer;
+               // The core rebuilds ISupport on module unload, but before the dtor.
+               ServerInstance->ISupport.Build();
                CheckForceQuit("National characters module unloaded");
                CheckRehash();
        }
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides an ability to have non-RFC1459 nicks & support for national CASEMAPPING", VF_VENDOR | VF_COMMON, charset);
+               return Version("Allows the server administrator to define what characters are allowed in nicknames and channel names and how those characters should be compared in a case insensitive way.", VF_VENDOR | VF_COMMON);
        }
 
        /*make an array to check against it 8bit characters a bit faster. Whether allowed or uppercase (for your needs).*/