3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-29 07:29:31 +01:00

fix truncation check

* The message target was not being counted :-(
* The additional character added to the target by STATUSMSG was not counted
This commit is contained in:
Shivaram Lingamneni 2024-06-10 23:20:22 -04:00
parent 2aec5e167c
commit 0b333c7e72
2 changed files with 6 additions and 5 deletions

View File

@ -1320,6 +1320,11 @@ func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mod
isBot := client.HasMode(modes.Bot) isBot := client.HasMode(modes.Bot)
chname := channel.Name() chname := channel.Name()
// STATUSMSG targets are prefixed with the supplied min-prefix, e.g., @#channel
if minPrefixMode != modes.Mode(0) {
chname = fmt.Sprintf("%s%s", modes.ChannelModePrefixes[minPrefixMode], chname)
}
if !client.server.Config().Server.Compatibility.allowTruncation { if !client.server.Config().Server.Compatibility.allowTruncation {
if !validateSplitMessageLen(histType, details.nickMask, chname, message) { if !validateSplitMessageLen(histType, details.nickMask, chname, message) {
rb.Add(nil, client.server.name, ERR_INPUTTOOLONG, details.nick, client.t("Line too long to be relayed without truncation")) rb.Add(nil, client.server.name, ERR_INPUTTOOLONG, details.nick, client.t("Line too long to be relayed without truncation"))
@ -1327,11 +1332,6 @@ func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mod
} }
} }
// STATUSMSG targets are prefixed with the supplied min-prefix, e.g., @#channel
if minPrefixMode != modes.Mode(0) {
chname = fmt.Sprintf("%s%s", modes.ChannelModePrefixes[minPrefixMode], chname)
}
if channel.flags.HasMode(modes.OpModerated) { if channel.flags.HasMode(modes.OpModerated) {
channel.stateMutex.RLock() channel.stateMutex.RLock()
cuData, ok := channel.members[client] cuData, ok := channel.members[client]

View File

@ -2184,6 +2184,7 @@ func validateLineLen(msgType history.ItemType, source, target, payload string) (
default: default:
return true return true
} }
limit -= len(target)
limit -= len(payload) limit -= len(payload)
return limit >= 0 return limit >= 0
} }