Handle plain nicks on +b/+e/+I and send error on invalid mask (non-strict)

This commit is contained in:
Les De Ridder 2020-10-15 16:59:57 +02:00
parent b5616c4a0b
commit cd7613ed70
1 changed files with 29 additions and 14 deletions

View File

@ -172,7 +172,7 @@ class Connection
} }
//NOTE: The RFCs don't specify what 'being idle' means //NOTE: The RFCs don't specify what 'being idle' means
// We assume that it's sending any message that isn't a PING/PONG. // We assume that it's sending any message that isn't a PING/PONG.
if (message.command != "PING" && message.command != "PONG") if (message.command != "PING" && message.command != "PONG")
{ {
lastMessageTime = Clock.currTime; lastMessageTime = Clock.currTime;
@ -863,10 +863,10 @@ class Connection
} }
//NOTE: The RFCs are ambiguous about the parameter(s). //NOTE: The RFCs are ambiguous about the parameter(s).
// It specifies one allowed parameter type, a space-separated list of nicknames (i.e. prefixed with ':'). // It specifies one allowed parameter type, a space-separated list of nicknames (i.e. prefixed with ':').
// However, the nicknames in the example are sent as separate parameters, not as a single string prefixed with ':'. // However, the nicknames in the example are sent as separate parameters, not as a single string prefixed with ':'.
// For this implementation, we assume the example is wrong, like most clients seem to assume as well. // For this implementation, we assume the example is wrong, like most clients seem to assume as well.
// (Other server implementations usually seem to support both interpretations.) // (Other server implementations usually seem to support both interpretations.)
_server.ison(this, message.parameters[0].split); _server.ison(this, message.parameters[0].split);
} }
@ -1061,15 +1061,15 @@ class Connection
switch (mode) switch (mode)
{ {
case 'i': case 'i':
case 'w': case 'w':
case 's': case 's':
if (add) if (add)
modes ~= mode; modes ~= mode;
else else
removeMode(mode); removeMode(mode);
break; break;
case 'o': case 'o':
case 'O': case 'O':
if (!add) if (!add)
removeMode(mode); removeMode(mode);
break; break;
@ -1198,20 +1198,35 @@ class Connection
processedParameters ~= memberNick; processedParameters ~= memberNick;
} }
break; break;
case 'b': //TODO: Implement bans case 'b':
case 'e': //TODO: Implement ban exceptions case 'e': //TODO: Implement ban exceptions
case 'I': //TODO: Implement invite lists case 'I': //TODO: Implement invite lists
if (i + 1 == message.parameters.length) if (i + 1 == message.parameters.length)
{ {
//TODO: Figure out what to do when we need more mode parameters //TODO: Figure out what to do when we need more mode parameters
break Lforeach; break Lforeach;
} }
auto mask = message.parameters[++i]; auto mask = message.parameters[++i];
//TODO: If RFC-strictness is off, interpret '<nick>' as '<nick>!*@*'
if (!Server.isValidUserMask(mask)) if (!Server.isValidUserMask(mask))
{ {
//TODO: If RFC-strictness is off, send an error //NOTE: The RFCs don't specify whether nicks are valid masks
break Lforeach; //NOTE: The RFCs don't allow an error reply on an invalid user mask
version (BasicFixes)
{
if (Server.isValidNick(mask))
{
mask ~= "!*@*";
}
else
{
sendMalformedMessageError(message.command, "Invalid user mask: " ~ mask);
break Lforeach;
}
}
else
{
break Lforeach;
}
} }
bool success; bool success;