|
@@ -19,8 +19,9 @@ const (
|
19
|
19
|
)
|
20
|
20
|
|
21
|
21
|
var (
|
22
|
|
- crlf = []byte{'\r', '\n'}
|
23
|
|
- errReadQ = errors.New("ReadQ Exceeded")
|
|
22
|
+ crlf = []byte{'\r', '\n'}
|
|
23
|
+ errReadQ = errors.New("ReadQ Exceeded")
|
|
24
|
+ errWSBinaryMessage = errors.New("WebSocket binary messages are unsupported")
|
24
|
25
|
)
|
25
|
26
|
|
26
|
27
|
// IRCConn abstracts away the distinction between a regular
|
|
@@ -148,11 +149,7 @@ func (wc IRCWSConn) UnderlyingConn() *utils.WrappedConn {
|
148
|
149
|
|
149
|
150
|
func (wc IRCWSConn) WriteLine(buf []byte) (err error) {
|
150
|
151
|
buf = bytes.TrimSuffix(buf, crlf)
|
151
|
|
- if !globalUtf8EnforcementSetting && !utf8.Valid(buf) {
|
152
|
|
- // there's not much we can do about this;
|
153
|
|
- // silently drop the message
|
154
|
|
- return nil
|
155
|
|
- }
|
|
152
|
+ // #1483: if we have websockets at all, then we're enforcing utf8
|
156
|
153
|
return wc.conn.WriteMessage(websocket.TextMessage, buf)
|
157
|
154
|
}
|
158
|
155
|
|
|
@@ -172,8 +169,7 @@ func (wc IRCWSConn) ReadLine() (line []byte, err error) {
|
172
|
169
|
if messageType == websocket.TextMessage {
|
173
|
170
|
return line, nil
|
174
|
171
|
} else {
|
175
|
|
- // for purposes of fakelag, treat non-text message as an empty line
|
176
|
|
- return nil, nil
|
|
172
|
+ return nil, errWSBinaryMessage
|
177
|
173
|
}
|
178
|
174
|
} else if err == websocket.ErrReadLimit {
|
179
|
175
|
return line, errReadQ
|