summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-27 21:44:44 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-27 21:44:44 +1000
commita6e6e1431d20a0f53ac639cd98703a2fd4803132 (patch)
tree3d3226f4b1e65597c6422d334902a0d6d1f7db7f
parentSet tutorial to null (diff)
downloadserver-a6e6e1431d20a0f53ac639cd98703a2fd4803132.tar.xz
Bad check for if buffer is json string instead of gzip
-rw-r--r--src/gateway/events/Message.ts4
1 files 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;