summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2021-02-27 01:30:45 +0000
committerSadie Powell <sadie@witchery.services>2021-02-27 01:30:45 +0000
commitaa885c1661979b43ab26a682e46ab93306ff8015 (patch)
treeaaf963a7c723e9fc1e19ee5925c531a1cd803725 /src
parent9ecea89f1251299a5431797976a7f1603f3c4bf8 (diff)
Fix not sending ERR_INVALIDMODEPARAM when a parameter is malformed.
Closes #1850.
Diffstat (limited to 'src')
-rw-r--r--src/mode.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index 1c17a6598..d183d0240 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -104,6 +104,14 @@ void ModeHandler::OnParameterMissing(User* user, User* dest, Channel* channel)
user->WriteNumeric(Numerics::InvalidModeParameter(dest, this, "*", message));
}
+void ModeHandler::OnParameterInvalid(User* user, Channel* targetchannel, User* targetuser, const std::string& parameter)
+{
+ if (targetchannel)
+ user->WriteNumeric(Numerics::InvalidModeParameter(targetchannel, this, "*"));
+ else
+ user->WriteNumeric(Numerics::InvalidModeParameter(targetuser, this, "*"));
+}
+
bool ModeHandler::ResolveModeConflict(std::string& theirs, const std::string& ours, Channel*)
{
return (theirs < ours);
@@ -403,7 +411,10 @@ static bool IsModeParamValid(User* user, Channel* targetchannel, User* targetuse
// The parameter cannot begin with a ':' character or contain a space
if ((item.param[0] == ':') || (item.param.find(' ') != std::string::npos))
+ {
+ item.mh->OnParameterInvalid(user, targetchannel, targetuser, item.param);
return false;
+ }
return true;
}