mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-11 06:29:29 +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:
parent
d547d05205
commit
e9d42e02a2
@ -126,10 +126,8 @@ func (wc IRCWSConn) WriteLines(buffers [][]byte) (err error) {
|
|||||||
func (wc IRCWSConn) ReadLine() (line []byte, err error) {
|
func (wc IRCWSConn) ReadLine() (line []byte, err error) {
|
||||||
messageType, line, err := wc.conn.ReadMessage()
|
messageType, line, err := wc.conn.ReadMessage()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if messageType == websocket.BinaryMessage && globalUtf8EnforcementSetting {
|
if messageType == websocket.BinaryMessage && !utf8.Valid(line) {
|
||||||
if !utf8.Valid(line) {
|
return line, errInvalidUtf8
|
||||||
return line, errInvalidUtf8
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return line, nil
|
return line, nil
|
||||||
} else if err == websocket.ErrReadLimit {
|
} else if err == websocket.ErrReadLimit {
|
||||||
|
Loading…
Reference in New Issue
Block a user