diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 2 | ||||
-rw-r--r-- | src/wildcard.cpp | 108 |
2 files changed, 59 insertions, 51 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 1f323e023..dd772f94e 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -444,7 +444,6 @@ InspIRCd::InspIRCd(int argc, char** argv) this->XLines = 0; this->Modes = 0; this->Res = 0; - this->national_case_sensitive_map = rfc_case_insensitive_map; // Initialise TIME this->TIME = time(NULL); @@ -986,6 +985,7 @@ void InspIRCd::SetSignal(int signal) */ ENTRYPOINT { + InspIRCd::national_case_sensitive_map = rfc_case_insensitive_map; SI = new InspIRCd(argc, argv); mysig = &SI->s_signal; SI->Run(); diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 63a28b8cb..9f91d9c68 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -19,54 +19,51 @@ static bool match_internal(const unsigned char *str, const unsigned char *mask, unsigned const char *map) { - unsigned char *cp = NULL, *mp = NULL; - unsigned char* string = (unsigned char*)str; - unsigned char* wild = (unsigned char*)mask; - - if (!map) - map = rfc_case_insensitive_map; - - while ((*string) && (*wild != '*')) - { - if ((map[*wild] != map[*string]) && (*wild != '?')) - { - return 0; - } - wild++; - string++; - } - - while (*string) - { - if (*wild == '*') - { - if (!*++wild) - { - return 1; - } - mp = wild; - cp = string+1; - } - else - if ((map[*wild] == map[*string]) || (*wild == '?')) - { - wild++; - string++; - } - else - { - wild = mp; - string = cp++; - } - - } - - while (*wild == '*') - { - wild++; - } - - return !*wild; + unsigned char *cp = NULL, *mp = NULL; + unsigned char* string = (unsigned char*)str; + unsigned char* wild = (unsigned char*)mask; + + while ((*string) && (*wild != '*')) + { + if ((map[*wild] != map[*string]) && (*wild != '?')) + { + return 0; + } + wild++; + string++; + } + + while (*string) + { + if (*wild == '*') + { + if (!*++wild) + { + return 1; + } + mp = wild; + cp = string+1; + } + else + if ((map[*wild] == map[*string]) || (*wild == '?')) + { + wild++; + string++; + } + else + { + wild = mp; + string = cp++; + } + + } + + while (*wild == '*') + { + wild++; + } + + return !*wild; } /******************************************************************** @@ -75,11 +72,16 @@ static bool match_internal(const unsigned char *str, const unsigned char *mask, CoreExport bool InspIRCd::Match(const std::string &str, const std::string &mask, unsigned const char *map) { + if (!map) + map = this->national_case_sensitive_map; + return match_internal((const unsigned char *)str.c_str(), (const unsigned char *)mask.c_str(), map); } CoreExport bool InspIRCd::Match(const char *str, const char *mask, unsigned const char *map) { + if (!map) + map = this->national_case_sensitive_map; return match_internal((const unsigned char *)str, (const unsigned char *)mask, map); } @@ -88,8 +90,11 @@ CoreExport bool InspIRCd::MatchCIDR(const std::string &str, const std::string &m if (irc::sockets::MatchCIDR(str, mask, true)) return true; + if (!map) + map = this->national_case_sensitive_map; + // Fall back to regular match - return InspIRCd::Match(str, mask, NULL); + return InspIRCd::Match(str, mask, map); } CoreExport bool InspIRCd::MatchCIDR(const char *str, const char *mask, unsigned const char *map) @@ -97,7 +102,10 @@ CoreExport bool InspIRCd::MatchCIDR(const char *str, const char *mask, unsigned if (irc::sockets::MatchCIDR(str, mask, true)) return true; + if (!map) + map = this->national_case_sensitive_map; + // Fall back to regular match - return InspIRCd::Match(str, mask, NULL); + return InspIRCd::Match(str, mask, map); } |