diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-12-07 18:31:54 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-12-07 18:31:54 +0000 |
commit | 6c389362435138c1523e4aedb53938100f6b4c47 (patch) | |
tree | 54450febbc1feb4af837c6c9b8f912d521efe0ad /src/wildcard.cpp | |
parent | 3c2c0b7733c0d752bdab4d42a33a3a777266b90a (diff) |
national_case_sensitive_map must be static, thanks to the match stuff being static (this is a bit ugly, but necessary for now).
Default to national charset map instead of rfc map, as modules may change the pointer.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10857 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/wildcard.cpp')
-rw-r--r-- | src/wildcard.cpp | 108 |
1 files changed, 58 insertions, 50 deletions
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); } |