From 23a506f04b2966caf939ea8ad166e8455095657c Mon Sep 17 00:00:00 2001 From: Daniel De Graaf Date: Fri, 19 Feb 2010 11:00:38 -0600 Subject: Read FJOIN lines more sensibly --- src/modules/m_spanningtree/fjoin.cpp | 64 +++++++++++++----------------------- 1 file changed, 23 insertions(+), 41 deletions(-) (limited to 'src/modules/m_spanningtree/fjoin.cpp') diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index a3ceddce2..b4ec1e189 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -122,49 +122,31 @@ CmdResult CommandFJoin::Handle(const std::vector& params, User *src /* Now, process every 'modes,nick' pair */ while (users.GetToken(item)) { - const char* usr = item.c_str(); - if (usr && *usr) + std::string::size_type comma = item.find(','); + if (comma == std::string::npos) + continue; + + std::string modes = item.substr(0, comma); + + /* Check the user actually exists */ + who = ServerInstance->FindUUID(item.substr(comma + 1)); + if (who) { - const char* unparsedmodes = usr; - std::string modes; - - - /* Iterate through all modes for this user and check they are valid. */ - while ((*unparsedmodes) && (*unparsedmodes != ',')) - { - ModeHandler *mh = ServerInstance->Modes->FindMode(*unparsedmodes, MODETYPE_CHANNEL); - if (mh) - modes += *unparsedmodes; - else - return CMD_INVALID; - - usr++; - unparsedmodes++; - } - - /* Advance past the comma, to the nick */ - usr++; - - /* Check the user actually exists */ - who = ServerInstance->FindUUID(usr); - if (who) - { - /* Check that the user's 'direction' is correct */ - TreeServer* route_back_again = Utils->BestRouteTo(who->server); - if ((!route_back_again) || (route_back_again->GetSocket() != src_socket)) - continue; - - /* Add any modes this user had to the mode stack */ - for (std::string::iterator x = modes.begin(); x != modes.end(); ++x) - modestack.push(irc::modechange(*x, MODETYPE_CHANNEL, who->nick, true)); - - Channel::JoinUser(who, channel.c_str(), true, "", route_back_again->bursting, TS); - } - else - { - ServerInstance->Logs->Log("m_spanningtree",SPARSE, "Ignored nonexistant user %s in fjoin to %s (probably quit?)", usr, channel.c_str()); + /* Check that the user's 'direction' is correct */ + TreeServer* route_back_again = Utils->BestRouteTo(who->server); + if ((!route_back_again) || (route_back_again->GetSocket() != src_socket)) continue; - } + + /* Add any modes this user had to the mode stack */ + for (std::string::iterator x = modes.begin(); x != modes.end(); ++x) + modestack.push(irc::modechange(*x, MODETYPE_CHANNEL, who->uuid, true)); + + Channel::JoinUser(who, channel.c_str(), true, "", route_back_again->bursting, TS); + } + else + { + ServerInstance->Logs->Log("m_spanningtree",SPARSE, "Ignored nonexistant user %s in fjoin to %s (probably quit?)", item.c_str(), channel.c_str()); + continue; } } -- cgit v1.3.1-10-gc9f91