Commit a083605 1 parent 0284933 commit a083605 Copy full SHA for a083605
File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ const {
12
12
websocketMessageReceived,
13
13
utf8Decode,
14
14
isControlFrame,
15
- isContinuationFrame
15
+ isContinuationFrame,
16
+ isTextBinaryFrame
16
17
} = require ( './util' )
17
18
const { WebsocketFrameSend } = require ( './frame' )
18
19
const { CloseEvent } = require ( './events' )
@@ -92,12 +93,19 @@ class ByteParser extends Writable {
92
93
93
94
const fragmented = ! fin && opcode !== opcodes . CONTINUATION
94
95
95
- if ( fragmented && opcode !== opcodes . BINARY && opcode !== opcodes . TEXT ) {
96
+ if ( fragmented && ! isTextBinaryFrame ( opcode ) ) {
96
97
// Only text and binary frames can be fragmented
97
98
failWebsocketConnection ( this . ws , 'Invalid frame type was fragmented.' )
98
99
return
99
100
}
100
101
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
+
101
109
const payloadLength = buffer [ 1 ] & 0x7F
102
110
103
111
if ( isControlFrame ( opcode ) ) {
You can’t perform that action at this time.
0 commit comments