X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcmd_nick.cpp;h=7779926e88e5686402ed4467803b452115a30fb7;hb=0dbb612a36296bff93db35abec4e87dc9bba1795;hp=83bb96859f39e15f054544ec2bf27830db321250;hpb=293df6a8b55e89c127e60e92711ef0ef1027bff8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp index 83bb96859..7779926e8 100644 --- a/src/cmd_nick.cpp +++ b/src/cmd_nick.cpp @@ -42,6 +42,7 @@ using namespace std; #include "xline.h" #include "inspstring.h" #include "dnsqueue.h" +#include "dns.h" #include "helperfuncs.h" #include "hashcomp.h" #include "socketengine.h" @@ -64,6 +65,8 @@ extern userrec* fd_ref_table[65536]; void cmd_nick::Handle (char **parameters, int pcnt, userrec *user) { + char oldnick[NICKMAX]; + if (pcnt < 1) { log(DEBUG,"not enough params for handle_nick"); @@ -89,9 +92,25 @@ void cmd_nick::Handle (char **parameters, int pcnt, userrec *user) log(DEBUG,"invalid old nick passed to handle_nick"); return; } - if (!strcasecmp(user->nick,parameters[0])) + if (irc::string(user->nick) == irc::string(parameters[0])) { - log(DEBUG,"old nick is new nick, skipping"); + /* If its exactly the same, even case, dont do anything. */ + if (!strcmp(user->nick,parameters[0])) + return; + /* Its a change of case. People insisted that they should be + * able to do silly things like this even though the RFC says + * the nick AAA is the same as the nick aaa. + */ + log(DEBUG,"old nick is new nick, not updating hash (case change only)"); + strlcpy(oldnick,user->nick,NICKMAX); + int MOD_RESULT = 0; + FOREACH_RESULT(OnUserPreNick(user,parameters[0])); + if (MOD_RESULT) + return; + strlcpy(user->nick,parameters[0],NICKMAX); + if (user->registered == 7) + WriteCommon(user,"NICK %s",parameters[0]); + FOREACH_MOD OnUserPostNick(user,oldnick); return; } else @@ -133,8 +152,7 @@ void cmd_nick::Handle (char **parameters, int pcnt, userrec *user) WriteCommon(user,"NICK %s",parameters[0]); } - - char oldnick[NICKMAX]; + strlcpy(oldnick,user->nick,NICKMAX); /* change the nick of the user in the users_hash */