From abc71684f30ab6e0479549caf91b674096255a2f Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 22 Jan 2023 14:42:58 -0500 Subject: [PATCH] always validate UTF8 from websockets --- irc/ircconn.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/irc/ircconn.go b/irc/ircconn.go index 8deb2a81..baeeb5cf 100644 --- a/irc/ircconn.go +++ b/irc/ircconn.go @@ -133,7 +133,7 @@ func (wc *IRCWSConn) WriteLines(buffers [][]byte) (err error) { } func (wc *IRCWSConn) ReadLine() (line []byte, err error) { - messageType, reader, err := wc.conn.NextReader() + _, reader, err := wc.conn.NextReader() switch err { case nil: // OK @@ -148,7 +148,7 @@ func (wc *IRCWSConn) ReadLine() (line []byte, err error) { case io.ErrUnexpectedEOF, io.EOF: // these are OK. io.ErrUnexpectedEOF is the good case: // it means we read the full message and it consumed less than the full wc.buf - if messageType == websocket.BinaryMessage && !utf8.Valid(line) { + if !utf8.Valid(line) { return line, errInvalidUtf8 } return line, nil