Fix IRC listener relay of bodies and modes, and JOIN names (closes #127)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The IRC listener relayed only the first line of a PRIVMSG or NOTICE body; it now sends one line per body line. A MODE change reached IRC listener members without its key, limit or mask, and "+o bob" went out as one trailing parameter; each value is now its own parameter, in the relay and in the echo to the IRC listener user who made the change. CR, LF and NUL are now removed from each parameter of a line sent to an IRC listener connection, before the leading ':' is decided, and from the whole line, so a stored body line, key or mask cannot start a line of its own. The channel name check moved from the HTTP handler into service.JoinChannel, so the IRC listener's JOIN refuses the same names with 403. Model: opus-5-5
This commit is contained in:
@@ -90,7 +90,10 @@ func ParseMessage(line string) *Message {
|
||||
}
|
||||
|
||||
// FormatMessage formats an IRC message into wire protocol
|
||||
// format (without the trailing CR-LF).
|
||||
// format (without the trailing CR-LF). CR, LF and NUL are
|
||||
// removed from each parameter, because on the wire they would
|
||||
// end the line early; this happens before deciding whether
|
||||
// the last parameter needs a leading ':'.
|
||||
func FormatMessage(
|
||||
prefix, command string,
|
||||
params ...string,
|
||||
@@ -106,6 +109,10 @@ func FormatMessage(
|
||||
buf.WriteString(command)
|
||||
|
||||
for i, param := range params {
|
||||
param = strings.ReplaceAll(param, "\r", "")
|
||||
param = strings.ReplaceAll(param, "\n", "")
|
||||
param = strings.ReplaceAll(param, "\x00", "")
|
||||
|
||||
buf.WriteByte(' ')
|
||||
|
||||
isLast := i == len(params)-1
|
||||
|
||||
Reference in New Issue
Block a user