From a3f306b9bab0113fa6d851d8c3014a746a0179fd Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Wed, 14 Oct 2020 07:23:19 +0200 Subject: [PATCH] Send error on invalid MODE operation (non-strict) --- source/ircd/connection.d | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/source/ircd/connection.d b/source/ircd/connection.d index 715b084..c347e03 100644 --- a/source/ircd/connection.d +++ b/source/ircd/connection.d @@ -1041,7 +1041,11 @@ class Connection auto add = modeString[0] == '+'; if (!add && modeString[0] != '-') { - //TODO: If RFC-strictness is off, send a malformed message error + //NOTE: The RFCs don't specify what should happen on malformed mode operations + version (BasicFixes) + { + sendMalformedMessageError(message.command, "Invalid mode operation: " ~ modeString[0]); + } continue; } @@ -1053,7 +1057,7 @@ class Connection auto changedModes = modeString[1 .. $]; foreach (mode; changedModes) { - //when RFC-strictness is off, maybe send an error when trying to do an illegal change + //TODO: If RFC-strictness is off, maybe send an error when trying to do an illegal change switch (mode) { case 'i': @@ -1132,7 +1136,11 @@ class Connection auto add = modeString[0] == '+'; if (!add && modeString[0] != '-') { - //TODO: If RFC-strictness is off, send a malformed message error + //NOTE: The RFCs don't specify what should happen on malformed mode operations + version (BasicFixes) + { + sendMalformedMessageError(message.command, "Invalid mode operation: " ~ modeString[0]); + } return; } @@ -1443,6 +1451,11 @@ class Connection ], true)); } + void sendMalformedMessageError(string command, string description) + { + send(Message(_server.name, "ERROR", [command, "Malformed message: " ~ description], true)); + } + void sendWelcome() { send(Message(_server.name, "001", [