]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
Backport fix for stripcolour not stripping colour codes, reported by jackmcbarn ...
[user/henk/code/inspircd.git] / src / mode.cpp
index 83aff70cf56400a4e64d29d89dc26cc196f65948..e5efaffdf0251e5eea61bb78a0d02690cdd883aa 100644 (file)
@@ -577,14 +577,23 @@ void ModeParser::Process(const char* const* parameters, int pcnt, User *user, bo
                                                        /* It's an oper only mode, check if theyre an oper. If they arent,
                                                         * eat any parameter that  came with the mode, and continue to next
                                                         */
-                                                       if ((IS_LOCAL(user)) && (modehandlers[handler_id]->NeedsOper()) && (!user->HasModePermission(modehandlers[handler_id]->GetModeChar(), type)))
+                                                       if (adding && (IS_LOCAL(user)) && (modehandlers[handler_id]->NeedsOper()) && (!user->HasModePermission(modehandlers[handler_id]->GetModeChar(), type)))
                                                        {
-                                                               user->WriteNumeric(481, "%s :Permission Denied - Oper type %s does not have access to %sset %s mode %c",
-                                                                               user->nick,
-                                                                               user->oper,
-                                                                               adding ? "" : "un",
-                                                                               type == MODETYPE_CHANNEL ? "channel" : "user",
-                                                                               modehandlers[handler_id]->GetModeChar());
+                                                               if (IS_OPER(user))
+                                                               {
+                                                                       user->WriteNumeric(481, "%s :Permission Denied - Oper type %s does not have access to set %s mode %c",
+                                                                                       user->nick,
+                                                                                       user->oper,
+                                                                                       type == MODETYPE_CHANNEL ? "channel" : "user",
+                                                                                       modehandlers[handler_id]->GetModeChar());
+                                                               }
+                                                               else
+                                                               {
+                                                                       user->WriteNumeric(481, "%s :Permission Denied - Only operators may set %s mode %c",
+                                                                                       user->nick,
+                                                                                       type == MODETYPE_CHANNEL ? "channel" : "user",
+                                                                                       modehandlers[handler_id]->GetModeChar());
+                                                               }
                                                                continue;
                                                        }
 
@@ -705,12 +714,12 @@ 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 */
+       std::string::size_type pos_of_colons = mask.find("::"); /* Because ipv6 addresses are colon delimited -- double so it treats extban as nick */
 
        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_colon == std::string::npos))
+               /* Just a nick, or just a host - or clearly ipv6 (starting with :) */
+               if ((pos_of_dot == std::string::npos) && (pos_of_colons == std::string::npos) && mask[0] != ':')
                {
                        /* It has no '.' in it, it must be a nick. */
                        mask.append("!*@*");
@@ -1116,9 +1125,8 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
                NULL
        };
 
-       /* Clear mode list */
+       /* Clear mode handler list */
        memset(modehandlers, 0, sizeof(modehandlers));
-       memset(modewatchers, 0, sizeof(modewatchers));
 
        /* Last parse string */
        LastParse.clear();