diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-03-06 22:28:57 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-03-06 22:28:57 +0000 |
commit | 526f5a4a02882b19056fe755dff1f64b764ff313 (patch) | |
tree | 6a9e92e4f3f7088b18dcdde360d07c911ee174df /src/command_parse.cpp | |
parent | eacd707421be4f2612df9bde4517649061bb062e (diff) |
Construct explicit parameter type list for MODE parameters
Previously, we used TR_SPACENICKLIST on the parameters. This worked only because
usually, if anything in the list parsed as a nick, then it was a nick. However,
some modes like +k and +g allow free-form text, which could also resolve as a
nick. Add extra parameters to allow modes to specify their TranslateType,
defaulting to TR_TEXT.
This fixes bug #757, found by Taros
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11180 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/command_parse.cpp')
-rw-r--r-- | src/command_parse.cpp | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 7c18c8ab1..d0b114816 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -609,32 +609,24 @@ void CommandParser::SetupCommandTable() this->CreateCommand(new CommandReload(ServerInstance)); } -int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, std::string &dest) +int CommandParser::TranslateUIDs(const std::vector<TranslateType> to, const std::string &source, std::string &dest) { + irc::spacesepstream items(source); + std::vector<TranslateType>::const_iterator types = to.begin(); User* user = NULL; std::string item; int translations = 0; dest.clear(); - switch (to) + while (items.GetToken(item)) { - case TR_NICK: - /* Translate single nickname */ - user = ServerInstance->FindNick(source); - if (user) - { - dest = user->uuid; - translations++; - } - else - dest = source; - break; - case TR_NICKLIST: + TranslateType t = *types; + types++; + + switch (t) { - /* Translate comma seperated list of nicknames */ - irc::commasepstream items(source); - while (items.GetToken(item)) - { + case TR_NICK: + /* Translate single nickname */ user = ServerInstance->FindNick(item); if (user) { @@ -643,31 +635,42 @@ int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, st } else dest.append(item); - dest.append(","); - } - if (!dest.empty()) - dest.erase(dest.end() - 1); + break; + break; + case TR_END: + case TR_TEXT: + default: + /* Do nothing */ + dest.append(item); + break; } - break; - case TR_SPACENICKLIST: - { - /* Translate space seperated list of nicknames */ - irc::spacesepstream items(source); - while (items.GetToken(item)) + dest.append(" "); + } + + if (!dest.empty()) + dest.erase(dest.end() - 1); + return translations; +} + +int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, std::string &dest) +{ + User* user = NULL; + std::string item; + int translations = 0; + dest.clear(); + + switch (to) + { + case TR_NICK: + /* Translate single nickname */ + user = ServerInstance->FindNick(source); + if (user) { - user = ServerInstance->FindNick(item); - if (user) - { - dest.append(user->uuid); - translations++; - } - else - dest.append(item); - dest.append(" "); + dest = user->uuid; + translations++; } - if (!dest.empty()) - dest.erase(dest.end() - 1); - } + else + dest = source; break; case TR_END: case TR_TEXT: |