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/mode.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/mode.cpp')
-rw-r--r-- | src/mode.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index e7f918e62..da8f10294 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -52,8 +52,8 @@ /* +s (server notice masks) */ #include "modes/umode_s.h" -ModeHandler::ModeHandler(InspIRCd* Instance, char modeletter, int parameters_on, int parameters_off, bool listmode, ModeType type, bool operonly, char mprefix, char prefixrequired) - : ServerInstance(Instance), mode(modeletter), n_params_on(parameters_on), n_params_off(parameters_off), list(listmode), m_type(type), oper(operonly), prefix(mprefix), count(0), prefixneeded(prefixrequired) +ModeHandler::ModeHandler(InspIRCd* Instance, char modeletter, int parameters_on, int parameters_off, bool listmode, ModeType type, bool operonly, char mprefix, char prefixrequired, TranslateType translate) + : ServerInstance(Instance), mode(modeletter), n_params_on(parameters_on), n_params_off(parameters_off), list(listmode), m_type(type), m_paramtype(translate), oper(operonly), prefix(mprefix), count(0), prefixneeded(prefixrequired) { } @@ -97,6 +97,11 @@ ModeType ModeHandler::GetModeType() return m_type; } +TranslateType ModeHandler::GetTranslateType() +{ + return m_paramtype; +} + bool ModeHandler::NeedsOper() { return oper; @@ -498,6 +503,8 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, std::string mode_sequence = parameters[1]; std::string parameter; std::ostringstream parameter_list; + std::vector<TranslateType> parameter_xlate; + parameter_xlate.push_back(TR_TEXT); std::string output_sequence; bool adding = true, state_change = false; unsigned char handler_id = 0; @@ -710,6 +717,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, if ((modehandlers[handler_id]->GetNumParams(adding)) && (!parameter.empty())) { parameter_list << " " << parameter; + parameter_xlate.push_back(modehandlers[handler_id]->GetTranslateType()); parameter_count++; /* Does this mode have a prefix? */ if (modehandlers[handler_id]->GetPrefix() && targetchannel) @@ -768,13 +776,13 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, if (type == MODETYPE_CHANNEL) { targetchannel->WriteChannel(user, "MODE %s %s%s", targetchannel->name.c_str(), output_sequence.c_str(), parameter_list.str().c_str()); - FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, output_sequence + parameter_list.str())); + FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, output_sequence + parameter_list.str(), parameter_xlate)); this->LastParse = targetchannel->name; } else { user->WriteTo(targetuser, "MODE %s %s%s", targetuser->nick.c_str(), output_sequence.c_str(), parameter_list.str().c_str()); - FOREACH_MOD(I_OnMode,OnMode(user, targetuser, TYPE_USER, output_sequence + parameter_list.str())); + FOREACH_MOD(I_OnMode,OnMode(user, targetuser, TYPE_USER, output_sequence + parameter_list.str(), parameter_xlate)); this->LastParse = targetuser->nick; } } |