From c461a94da060f0c0e1d5fb96c6d60343517ad7d4 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Tue, 27 Sep 2022 21:44:44 +1000 Subject: [PATCH] Bad check for if buffer is json string instead of gzip --- src/gateway/events/Message.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts index 603f68fa..e8cbe964 100644 --- a/src/gateway/events/Message.ts +++ b/src/gateway/events/Message.ts @@ -25,7 +25,7 @@ export async function Message(this: WebSocket, buffer: WS.Data) { if (this.encoding === "etf" && buffer instanceof Buffer) data = erlpack.unpack(buffer); - else if (this.encoding === "json" && buffer instanceof Buffer) { + else if (this.encoding === "json" && buffer instanceof Buffer && buffer[0] !== 123) { // bad check for "{" if (this.inflate) { try { buffer = this.inflate.process(buffer) as any; @@ -34,7 +34,7 @@ export async function Message(this: WebSocket, buffer: WS.Data) { } } data = bigIntJson.parse(buffer as string); - } else if (typeof buffer == "string") { + } else if (typeof buffer == "string" || (buffer instanceof Buffer && buffer[0] == 123)) { data = bigIntJson.parse(buffer as string); } else return;