1
0
Fork 0
forked from External/ergo

Restrict idents as other servers do

This commit is contained in:
Daniel Oaks 2019-02-03 18:49:42 +10:00
parent 9f25a42c3d
commit 8cd5db1194
5 changed files with 49 additions and 4 deletions

View file

@ -623,12 +623,15 @@ func (client *Client) HasUsername() bool {
return client.username != "" && client.username != "*"
}
// SetNames sets the client's ident and realname.
func (client *Client) SetNames(username, realname string) error {
usernameCasefolded, err := CasefoldName(username)
if err != nil {
// do this before casefolding to ensure these are actually ascii
if !isIdent(username) {
return errInvalidUsername
}
usernameCasefolded := strings.ToLower(username) // only ascii is supported in idents anyway
client.stateMutex.Lock()
defer client.stateMutex.Unlock()