Skip to content

Commit a083605

Browse files
committed
fix case 5.18
1 parent 0284933 commit a083605

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/web/websocket/receiver.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const {
1212
websocketMessageReceived,
1313
utf8Decode,
1414
isControlFrame,
15-
isContinuationFrame
15+
isContinuationFrame,
16+
isTextBinaryFrame
1617
} = require('./util')
1718
const { WebsocketFrameSend } = require('./frame')
1819
const { CloseEvent } = require('./events')
@@ -92,12 +93,19 @@ class ByteParser extends Writable {
9293

9394
const fragmented = !fin && opcode !== opcodes.CONTINUATION
9495

95-
if (fragmented && opcode !== opcodes.BINARY && opcode !== opcodes.TEXT) {
96+
if (fragmented && !isTextBinaryFrame(opcode)) {
9697
// Only text and binary frames can be fragmented
9798
failWebsocketConnection(this.ws, 'Invalid frame type was fragmented.')
9899
return
99100
}
100101

102+
// If we are already parsing a text/binary frame and do not receive either
103+
// a continuation frame or close frame, fail the connection.
104+
if (isTextBinaryFrame(opcode) && this.#info.opcode !== undefined) {
105+
failWebsocketConnection(this.ws, 'Expected continuation frame')
106+
return
107+
}
108+
101109
const payloadLength = buffer[1] & 0x7F
102110

103111
if (isControlFrame(opcode)) {

0 commit comments

Comments
 (0)