3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 13:29:27 +01:00
All truncation must be made UTF8-safe.
This commit is contained in:
Shivaram Lingamneni 2021-03-18 03:49:12 -04:00
parent cd43fae478
commit e447c61c73
2 changed files with 8 additions and 13 deletions

View File

@ -13,6 +13,8 @@ import (
"sync"
"github.com/goshuirc/irc-go/ircutils"
"github.com/oragono/oragono/irc/caps"
"github.com/oragono/oragono/irc/history"
"github.com/oragono/oragono/irc/modes"
@ -1259,10 +1261,7 @@ func (channel *Channel) SetTopic(client *Client, topic string, rb *ResponseBuffe
return
}
topicLimit := client.server.Config().Limits.TopicLen
if len(topic) > topicLimit {
topic = topic[:topicLimit]
}
topic = ircutils.TruncateUTF8Safe(topic, client.server.Config().Limits.TopicLen)
channel.stateMutex.Lock()
chname := channel.name
@ -1520,10 +1519,7 @@ func (channel *Channel) Kick(client *Client, target *Client, comment string, rb
return
}
kicklimit := channel.server.Config().Limits.KickLen
if len(comment) > kicklimit {
comment = comment[:kicklimit]
}
comment = ircutils.TruncateUTF8Safe(comment, channel.server.Config().Limits.KickLen)
message := utils.MakeMessage(comment)
details := client.Details()

View File

@ -22,6 +22,9 @@ import (
"github.com/goshuirc/irc-go/ircfmt"
"github.com/goshuirc/irc-go/ircmsg"
"github.com/goshuirc/irc-go/ircutils"
"golang.org/x/crypto/bcrypt"
"github.com/oragono/oragono/irc/caps"
"github.com/oragono/oragono/irc/custime"
"github.com/oragono/oragono/irc/flatip"
@ -30,7 +33,6 @@ import (
"github.com/oragono/oragono/irc/modes"
"github.com/oragono/oragono/irc/sno"
"github.com/oragono/oragono/irc/utils"
"golang.org/x/crypto/bcrypt"
)
// helper function to parse ACC callbacks, e.g., mailto:person@example.com, tel:16505551234
@ -346,10 +348,7 @@ func awayHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respons
if len(msg.Params) > 0 {
isAway = true
awayMessage = msg.Params[0]
awayLen := server.Config().Limits.AwayLen
if len(awayMessage) > awayLen {
awayMessage = awayMessage[:awayLen]
}
awayMessage = ircutils.TruncateUTF8Safe(awayMessage, server.Config().Limits.AwayLen)
}
rb.session.SetAway(awayMessage)