3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-04-22 07:47:56 +02:00
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
}