simplify utf8 validation of incoming WS lines

As of #1483, websockets entail enforce-utf8, so there's no need
to check globalUTF8EnforcementSetting when handling websockets.
This commit is contained in:
Shivaram Lingamneni 2021-02-26 03:10:30 -05:00
parent d547d05205
commit e9d42e02a2
1 changed files with 2 additions and 4 deletions

View File

@ -126,10 +126,8 @@ func (wc IRCWSConn) WriteLines(buffers [][]byte) (err error) {
func (wc IRCWSConn) ReadLine() (line []byte, err error) {
messageType, line, err := wc.conn.ReadMessage()
if err == nil {
if messageType == websocket.BinaryMessage && globalUtf8EnforcementSetting {
if !utf8.Valid(line) {
return line, errInvalidUtf8
}
if messageType == websocket.BinaryMessage && !utf8.Valid(line) {
return line, errInvalidUtf8
}
return line, nil
} else if err == websocket.ErrReadLimit {