]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_redirect.cpp
Decide that it wasn't quite appropriate :(
[user/henk/code/inspircd.git] / src / modules / m_redirect.cpp
index 28c0923065e20c30459bd9f977a3c2232089e1ee..a91ddef7f6104d0d00424a8e1add07f2cfd956bf 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
  *                       E-mail:
  *                <brain@chatspike.net>
  *               <Craig@chatspike.net>
@@ -45,10 +45,19 @@ class ModuleRedirect : public Module
                        if (mode_on)
                        {
                                std::string ChanToJoin = params[0];
-                               chanrec* c = Srv->FindChannel(ChanToJoin);
+                               chanrec *c;
+
+                               if (!IsValidChannelName(ChanToJoin.c_str()))
+                               {
+                                       WriteServ(user->fd,"403 %s %s :Invalid channel name",user->nick, ChanToJoin.c_str());
+                                       return 0;
+                               }
+
+                               c = Srv->FindChannel(ChanToJoin);
                                if (c)
                                {
-                                       if (c->IsCustomModeSet('L'))
+                                       /* Fix by brain: Dont let a channel be linked to *itself* either */
+                                       if ((c == target) || (c->IsCustomModeSet('L')))
                                        {
                                                WriteServ(user->fd,"690 %s :Circular redirection, mode +L to %s not allowed.",user->nick,params[0].c_str());
                                                return 0;
@@ -60,25 +69,15 @@ class ModuleRedirect : public Module
                return 0;
        }
 
-        virtual void On005Numeric(std::string &output)
-        {
-                std::stringstream line(output);
-                std::string temp1, temp2;
-                while (!line.eof())
-                {
-                        line >> temp1;
-                        if (temp1.substr(0,10) == "CHANMODES=")
-                        {
-                               // By doing this we're *assuming* no other module has fucked up the CHANMODES=
-                               // section of the 005 numeric. If they have, we're going DOWN in a blaze of glory,
-                               // with a honking great EXCEPTION :)
-                               temp1.insert(temp1.find(",")+1,"L");
-                        }
-                        temp2 = temp2 + temp1 + " ";
-                }
-               if (temp2.length())
-                       output = temp2.substr(0,temp2.length()-1);
-        }
+       void Implements(char* List)
+       {
+               List[I_On005Numeric] = List[I_OnUserPreJoin] = List[I_OnExtendedMode] = 1;
+       }
+
+       virtual void On005Numeric(std::string &output)
+       {
+               InsertMode(output, "L", 3);
+       }
        
        virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
        {
@@ -106,11 +105,6 @@ class ModuleRedirect : public Module
        {
                return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
        }
-       
-       virtual void OnUserConnect(userrec* user)
-       {
-       }
-
 };