mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 21:39:25 +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,11 +126,9 @@ 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 {
|
||||||
return line, ircreader.ErrReadQ
|
return line, ircreader.ErrReadQ
|
||||||
|
Loading…
Reference in New Issue
Block a user