]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Fix sending the wrong numerics on join when a topic is empty.
[user/henk/code/inspircd.git] / src / channels.cpp
index 73d408fb851e5596b48fe9dc7e3b44f837a80407..6802e3d7dd7d049468dbe0ce6f52ad2a3171df20 100644 (file)
@@ -202,10 +202,18 @@ void Channel::SetDefaultModes()
                if (mode)
                {
                        if (mode->GetNumParams(true))
+                       {
                                list.GetToken(parameter);
+                               // If the parameter begins with a ':' then it's invalid
+                               if (parameter.c_str()[0] == ':')
+                                       continue;
+                       }
                        else
                                parameter.clear();
 
+                       if ((mode->GetNumParams(true)) && (parameter.empty()))
+                               continue;
+
                        mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true);
                }
        }
@@ -404,7 +412,7 @@ Channel* Channel::ForceChan(Channel* Ptr, User* user, const std::string &privs,
 
        if (IS_LOCAL(user))
        {
-               if (Ptr->topicset)
+               if (!Ptr->topic.empty())
                {
                        user->WriteNumeric(RPL_TOPIC, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str());
                        user->WriteNumeric(RPL_TOPICTIME, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset);
@@ -783,6 +791,7 @@ void Channel::UserList(User *user)
         */
        bool has_user = this->HasUser(user);
 
+       const size_t maxlen = MAXBUF - 10 - ServerInstance->Config->ServerName.size();
        std::string prefixlist;
        std::string nick;
        for (UserMembIter i = userlist.begin(); i != userlist.end(); ++i)
@@ -807,7 +816,7 @@ void Channel::UserList(User *user)
                if (nick.empty())
                        continue;
 
-               if (list.size() + prefixlist.length() + nick.length() + 1 > 480)
+               if (list.size() + prefixlist.length() + nick.length() + 1 > maxlen)
                {
                        /* list overflowed into multiple numerics */
                        user->WriteNumeric(RPL_NAMREPLY, list);