3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-05-05 14:17:36 +02:00

disallow initial $ in nicknames

It collides with the massmessage mask syntax. Reported by @emersion
This commit is contained in:
Shivaram Lingamneni 2021-12-06 14:17:45 -05:00
parent 3e32e3f19e
commit f40d868cf5

View File

@ -97,9 +97,15 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
realname := client.realname realname := client.realname
client.stateMutex.RUnlock() client.stateMutex.RUnlock()
if newNick != accountName && strings.ContainsAny(newNick, disfavoredNameCharacters) { // 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 return "", errNicknameInvalid, false
} }
}
// recompute always-on status, because client.alwaysOn is not set for unregistered clients // recompute always-on status, because client.alwaysOn is not set for unregistered clients
var alwaysOn, useAccountName bool var alwaysOn, useAccountName bool