Merge pull request #2124 from slingamn/realnamelimit

fix #2123
This commit is contained in:
Shivaram Lingamneni 2024-02-10 23:25:31 -05:00 committed by GitHub
commit 24ac3b68b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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"`

View File

@ -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 {

View File

@ -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