fix: check the format of the event name · socketio/socket.io-devalue-parser@2dc3c92 · GitHub
Skip to content

Commit 2dc3c92

Browse files
fix: check the format of the event name
A packet like '2[{"toString":"foo"}]' was decoded as: { type: EVENT, data: [ { "toString": "foo" } ] } Which would then throw an error when passed to the EventEmitter class: > TypeError: Cannot convert object to primitive value > at Socket.emit (node:events:507:25) > at .../node_modules/socket.io/lib/socket.js:531:14 History of the isPayloadValid() method: - added in [78f9fc2](78f9fc2) (v4.0.1, socket.io@3.0.0) - updated in [1c220dd](1c220dd) (v4.0.4, socket.io@3.1.0) Backported from socketio@3b78117
1 parent 4b3c191 commit 2dc3c92

3 files changed

Lines changed: 38 additions & 11 deletions

File tree

index.js

Lines changed: 22 additions & 3 deletions

test/arraybuffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('parser', function() {
5050
it('cleans itself up on close', function() {
5151
var packet = {
5252
type: parser.BINARY_EVENT,
53-
data: [new ArrayBuffer(2), new ArrayBuffer(3)],
53+
data: ["foo", new ArrayBuffer(2), new ArrayBuffer(3)],
5454
id: 0,
5555
nsp: '/'
5656
};

test/parser.js

Lines changed: 15 additions & 7 deletions

0 commit comments

Comments
 (0)