fix #2244 (#2247)
Some checks failed
build / build (push) Has been cancelled
ghcr / Build (push) Has been cancelled

Fix #2244

Produce an explicit error on receiving the UTF-8 BOM
This commit is contained in:
Shivaram Lingamneni 2025-04-21 22:37:53 -04:00 committed by GitHub
parent 68cee9e2cd
commit 5bab190d33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,6 +71,10 @@ const (
PingCoalesceThreshold = time.Second
)
const (
utf8BOM = "\xef\xbb\xbf"
)
var (
MaxLineLen = DefaultMaxLineLen
)
@ -750,7 +754,11 @@ func (client *Client) run(session *Session) {
continue
} // else: proceed with the truncated line
} else if err != nil {
client.Quit(client.t("Received malformed line"), session)
message := "Received malformed line"
if strings.HasPrefix(line, utf8BOM) {
message = "Received UTF-8 byte-order mark, which is invalid at the start of an IRC protocol message"
}
client.Quit(message, session)
break
}