From 323a5650f0226c38a1c4255ae4475286cc93428c Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Thu, 1 Aug 2024 16:41:07 +0800 Subject: [PATCH] fix(core): allow non-json body type when parsing (#6379) --- packages/core/src/oidc/init.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/src/oidc/init.ts b/packages/core/src/oidc/init.ts index b4a7b94a3..8469f2e8e 100644 --- a/packages/core/src/oidc/init.ts +++ b/packages/core/src/oidc/init.ts @@ -400,10 +400,10 @@ export default function initOidc( // 'application/json' for body parsing. Update relatively when we enable that feature. if (ctx.is(jsonContentType)) { ctx.headers['content-type'] = formUrlEncodedContentType; - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - ctx.request.body = JSON.parse(body); + // eslint-disable-next-line no-restricted-syntax + ctx.request.body = trySafe(() => JSON.parse(body) as unknown); } else if (ctx.is(formUrlEncodedContentType)) { - ctx.request.body = querystring.parse(body); + ctx.request.body = trySafe(() => querystring.parse(body)); } }