Skip to content

Commit

Permalink
fix #2123
Browse files Browse the repository at this point in the history
Add a configurable limit on realname length
  • Loading branch information
slingamn committed Feb 8, 2024
1 parent d97e964 commit 921651f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions irc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 4 additions & 0 deletions irc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions traditional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 921651f

Please sign in to comment.