3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-13 07:29:30 +01:00

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

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 {