From 467df249146cda8cd267934bc6ff63f97d6ad867 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sat, 22 Mar 2025 23:13:31 -0400 Subject: [PATCH] fix #2228 (#2233) If the server is UTF8ONLY, validate that the MOTD is UTF8 --- irc/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/irc/config.go b/irc/config.go index bbbb8aee..2ad0a97d 100644 --- a/irc/config.go +++ b/irc/config.go @@ -22,6 +22,7 @@ import ( "strconv" "strings" "time" + "unicode/utf8" "code.cloudfoundry.org/bytefmt" "github.com/ergochat/irc-go/ircfmt" @@ -1864,6 +1865,9 @@ func (config *Config) loadMOTD() error { if config.Server.MOTDFormatting { lineToSend = ircfmt.Unescape(lineToSend) } + if config.Server.EnforceUtf8 && !utf8.ValidString(lineToSend) { + return fmt.Errorf("Line %d of MOTD contains invalid UTF8", i+1) + } // "- " is the required prefix for MOTD lineToSend = fmt.Sprintf("- %s", lineToSend) config.Server.motdLines = append(config.Server.motdLines, lineToSend)