diff --git a/default.yaml b/default.yaml index 7936a766..922f3717 100644 --- a/default.yaml +++ b/default.yaml @@ -820,6 +820,9 @@ limits: # identlen is the max ident length allowed identlen: 20 + # realnamelen is the maximum realname length allowed + realnamelen: 150 + # channellen is the max channel length allowed channellen: 64 diff --git a/irc/config.go b/irc/config.go index 3649efd1..8b1312fa 100644 --- a/irc/config.go +++ b/irc/config.go @@ -484,6 +484,7 @@ type Limits struct { ChanListModes int `yaml:"chan-list-modes"` ChannelLen int `yaml:"channellen"` IdentLen int `yaml:"identlen"` + RealnameLen int `yaml:"realnamelen"` KickLen int `yaml:"kicklen"` MonitorEntries int `yaml:"monitor-entries"` NickLen int `yaml:"nicklen"` diff --git a/irc/handlers.go b/irc/handlers.go index 520f26c1..cfe98572 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -3334,6 +3334,10 @@ func userHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respons rb.Add(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), "USER", client.t("Not enough parameters")) return false } + config := server.Config() + if config.Limits.RealnameLen > 0 && len(realname) > config.Limits.RealnameLen { + realname = ircmsg.TruncateUTF8Safe(realname, config.Limits.RealnameLen) + } // #843: we accept either: `USER user:pass@clientid` or `USER user@clientid` if strudelIndex := strings.IndexByte(username, '@'); strudelIndex != -1 { diff --git a/traditional.yaml b/traditional.yaml index 22d2b550..84f7b861 100644 --- a/traditional.yaml +++ b/traditional.yaml @@ -792,6 +792,9 @@ limits: # identlen is the max ident length allowed identlen: 20 + # realnamelen is the maximum realname length allowed + realnamelen: 150 + # channellen is the max channel length allowed channellen: 64