From f40d868cf58cf20dea9e2638d2e492a6eee4ba61 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 6 Dec 2021 14:17:45 -0500 Subject: [PATCH] disallow initial $ in nicknames It collides with the massmessage mask syntax. Reported by @emersion --- irc/client_lookup_set.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/irc/client_lookup_set.go b/irc/client_lookup_set.go index 8d96e021..833e7876 100644 --- a/irc/client_lookup_set.go +++ b/irc/client_lookup_set.go @@ -97,8 +97,14 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick realname := client.realname client.stateMutex.RUnlock() - if newNick != accountName && strings.ContainsAny(newNick, disfavoredNameCharacters) { - return "", errNicknameInvalid, false + // these restrictions have grandfather exceptions for nicknames registered + // on previous versions of Ergo: + if newNick != accountName { + // can't contain "disfavored" characters like <, or start with a $ because + // it collides with the massmessage mask syntax: + if strings.ContainsAny(newNick, disfavoredNameCharacters) || strings.HasPrefix(newNick, "$") { + return "", errNicknameInvalid, false + } } // recompute always-on status, because client.alwaysOn is not set for unregistered clients