Pārlūkot izejas kodu

always validate UTF8 from websockets

tags/v2.12.0-rc1
Shivaram Lingamneni 1 gadu atpakaļ
vecāks
revīzija
abc71684f3
1 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  1. 2
    2
      irc/ircconn.go

+ 2
- 2
irc/ircconn.go Parādīt failu

133
 }
133
 }
134
 
134
 
135
 func (wc *IRCWSConn) ReadLine() (line []byte, err error) {
135
 func (wc *IRCWSConn) ReadLine() (line []byte, err error) {
136
-	messageType, reader, err := wc.conn.NextReader()
136
+	_, reader, err := wc.conn.NextReader()
137
 	switch err {
137
 	switch err {
138
 	case nil:
138
 	case nil:
139
 		// OK
139
 		// OK
148
 	case io.ErrUnexpectedEOF, io.EOF:
148
 	case io.ErrUnexpectedEOF, io.EOF:
149
 		// these are OK. io.ErrUnexpectedEOF is the good case:
149
 		// these are OK. io.ErrUnexpectedEOF is the good case:
150
 		// it means we read the full message and it consumed less than the full wc.buf
150
 		// it means we read the full message and it consumed less than the full wc.buf
151
-		if messageType == websocket.BinaryMessage && !utf8.Valid(line) {
151
+		if !utf8.Valid(line) {
152
 			return line, errInvalidUtf8
152
 			return line, errInvalidUtf8
153
 		}
153
 		}
154
 		return line, nil
154
 		return line, nil

Notiek ielāde…
Atcelt
Saglabāt