Browse Source

Fixed parsing issue with IRCv3 MODE messages

release/1.0.1
Jessica James 4 years ago
parent
commit
ffe56f8f1d
  1. 39
      src/common/IRC_Client.cpp

39
src/common/IRC_Client.cpp

@ -1082,37 +1082,44 @@ int Jupiter::IRC::Client::process_line(const Jupiter::ReadableString &line)
Jupiter::ReferenceString modes = modestring.getWord(0, " "); Jupiter::ReferenceString modes = modestring.getWord(0, " ");
if (modes.isNotEmpty()) if (modes.isNotEmpty())
{ {
modestring.shiftRight(modestring.find(' ') + 1); Jupiter::ReferenceString modeParameters = modestring.gotoWord(1, " ");
Jupiter::ReferenceString tword; Jupiter::ReferenceString tword;
unsigned char g = 0; unsigned char word_index = 0;
char symb = 0; char symb = 0;
for (uint8_t z = 0; z != modes.size(); z++) for (uint8_t mode_index = 0; mode_index != modes.size(); mode_index++)
{ {
if (modes[z] == '+' || modes[z] == '-') if (modes[mode_index] == '+' || modes[mode_index] == '-')
symb = modes[z]; symb = modes[mode_index];
else if (m_prefix_modes.contains(modes[z])) // user prefix mode else if (m_prefix_modes.contains(modes[mode_index])) // user prefix mode
{ {
tword = modeParameters.getWord(word_index, " ");
if (tword.isNotEmpty() && tword[0] == ':') {
// Sttrip leading ':'
tword.shiftRight(1);
// erase modeParameters
modeParameters.erase();
}
tword = modestring.getWord(g, " ");
if (tword.isNotEmpty()) if (tword.isNotEmpty())
{ {
Jupiter::IRC::Client::Channel *channel = getChannel(chan); Jupiter::IRC::Client::Channel *channel = getChannel(chan);
if (channel != nullptr) if (channel != nullptr)
{ {
if (symb == '+') if (symb == '+')
channel->addUserPrefix(Jupiter::ReferenceString(tword), m_prefixes[m_prefix_modes.find(modes[z])]); channel->addUserPrefix(tword, m_prefixes[m_prefix_modes.find(modes[mode_index])]);
else else
channel->delUserPrefix(Jupiter::ReferenceString(tword), m_prefixes[m_prefix_modes.find(modes[z])]); channel->delUserPrefix(tword, m_prefixes[m_prefix_modes.find(modes[mode_index])]);
} }
} }
g++; ++word_index;
} }
else if (m_modeA.contains(modes[z])) // mode type A else if (m_modeA.contains(modes[mode_index])) // mode type A
g++; ++word_index;
else if (m_modeB.contains(modes[z])) // mode type B else if (m_modeB.contains(modes[mode_index])) // mode type B
g++; ++word_index;
else if (m_modeC.contains(modes[z]) && symb == '+') // mode type C (with parameter) else if (m_modeC.contains(modes[mode_index]) && symb == '+') // mode type C (with parameter)
g++; ++word_index;
// else; // mode type D // else; // mode type D
} }
} }

Loading…
Cancel
Save