summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-07 21:24:44 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-07 21:24:44 +0000
commit24d7bd0a26f92c81990aa740b7c09e3722c838fe (patch)
treefc684f02bfe0c77ca32586a15829addaf5d4f2c4 /src
parentd9f48b75602a6363fc5f50c53bd1fc6d1b96e3bd (diff)
Mask cleaning.
nick -> nick!*@* nick!ident -> nick!ident@* host.name -> *!*@host.name ident@host.name -> *!ident@host.name transposed @ and !, swap @ and ! to form proper n!u@h ordering Hostname determined by containing a dot or a colon git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4147 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/mode.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 596233cfd..9607a1b4c 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -571,6 +571,43 @@ void ModeParser::CleanMask(std::string &mask)
{
std::string::size_type pos_of_pling = mask.find_first_of('!');
std::string::size_type pos_of_at = mask.find_first_of('@');
+ std::string::size_type pos_of_dot = mask.find_first_of('.');
+ std::string::size_type pos_of_colon = mask.find_first_of(':'); /* Because ipv6 addresses are colon delimited */
+
+ if ((pos_of_pling == std::string::npos) && (pos_of_at == std::string::npos))
+ {
+ /* Just a nick, or just a host */
+ if ((pos_of_dot == std::string::npos) && (pos_of_dot == std::string::npos))
+ {
+ /* It has no '.' in it, it must be a nick. */
+ mask.append("!*@*");
+ }
+ else
+ {
+ /* Got a dot in it? Has to be a host */
+ mask = "*!*@" + mask;
+ }
+ }
+ else if ((pos_of_pling == std::string::npos) && (pos_of_at != std::string::npos))
+ {
+ /* Has an @ but no !, its a user@host */
+ mask = "*!" + mask;
+ }
+ else if ((pos_of_pling != std::string::npos) && (pos_of_at == std::string::npos))
+ {
+ /* Has a ! but no @, it must be a nick!ident */
+ mask.append("@*");
+ }
+
+ /* Check for dumb stuff like *@*!*
+ * swap the two items over so that at least the n!u@h ordering
+ * is correct even if the elements may not be
+ */
+ if (pos_of_pling > pos_of_at)
+ {
+ mask.replace(pos_of_pling, 1, "@");
+ mask.replace(pos_of_at, 1, "!");
+ }
}
bool ModeParser::AddMode(ModeHandler* mh, unsigned const char modeletter)