From dcf73354ff173c0407c62f84ea3bb90a130303c1 Mon Sep 17 00:00:00 2001 From: Zed Date: Sat, 1 Jul 2023 22:07:37 +0200 Subject: [PATCH] Fix GraphQL user crash with invalid JSON --- src/experimental/parser/graphql.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/experimental/parser/graphql.nim b/src/experimental/parser/graphql.nim index 36014e3..0f08c4f 100644 --- a/src/experimental/parser/graphql.nim +++ b/src/experimental/parser/graphql.nim @@ -4,6 +4,9 @@ import user, ../types/[graphuser, graphlistmembers] from ../../types import User, Result, Query, QueryKind proc parseGraphUser*(json: string): User = + if json.len == 0 or json[0] != '{': + return + let raw = json.fromJson(GraphUser) if raw.data.user.result.reason.get("") == "Suspended":