Skip to content

Commit

Permalink
Merge pull request #2170 from slingamn/validate.1
Browse files Browse the repository at this point in the history
fix truncation check
  • Loading branch information
slingamn committed Jun 11, 2024
2 parents 2aec5e1 + 2bb0a9c commit 9b8562c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions irc/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1320,18 +1320,18 @@ func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mod
isBot := client.HasMode(modes.Bot)
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 !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"))
return
}
}

// 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) {
channel.stateMutex.RLock()
cuData, ok := channel.members[client]
Expand Down
1 change: 1 addition & 0 deletions irc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,7 @@ func validateLineLen(msgType history.ItemType, source, target, payload string) (
default:
return true
}
limit -= len(target)
limit -= len(payload)
return limit >= 0
}
Expand Down
2 changes: 1 addition & 1 deletion irctest

0 comments on commit 9b8562c

Please sign in to comment.