diff options
| author | 2026-04-08 16:04:39 +0100 | |
|---|---|---|
| committer | 2026-04-08 16:39:09 +0100 | |
| commit | 2c34aec1cf9e67f9e74dfd56f1b7a18cdddaf311 (patch) | |
| tree | 943dbc9af0d1f5ffca68dc8ef5360a3962da0193 | |
| parent | Fix the Windows RC using the wrong version variable. (diff) | |
Truncate overly-long usernames in USER.
| -rw-r--r-- | src/coremods/core_user/cmd_user.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/coremods/core_user/cmd_user.cpp b/src/coremods/core_user/cmd_user.cpp index b1a337ad1..a8a795858 100644 --- a/src/coremods/core_user/cmd_user.cpp +++ b/src/coremods/core_user/cmd_user.cpp @@ -42,10 +42,16 @@ CommandUser::CommandUser(Module* parent) CmdResult CommandUser::HandleLocal(LocalUser* user, const Params& parameters) { /* A user may only send the USER command once */ - const auto& newuser = parameters[0]; const auto& newreal = parameters[3]; if (!(user->connected & User::CONN_USER)) { + // If the username is too long then we have to truncate it to mimic the + // undocumented behaviour of other IRC servers. Failing to do so will + // break clients. + auto newuser = parameters[0]; + if (newuser.length() > ServerInstance->Config->Limits.MaxUser) + newuser.erase(ServerInstance->Config->Limits.MaxUser); + if (!ServerInstance->IsUser(newuser)) { user->WriteNumeric(ERR_INVALIDUSERNAME, newuser, "Your username is not valid"); |
