From a8871770c129378fdb68f66d3d7c8a39ac3b98b2 Mon Sep 17 00:00:00 2001 From: Vicky Bansal <67091118+vicky-primathon@users.noreply.github.com> Date: Mon, 9 Aug 2021 17:48:58 +0530 Subject: [PATCH] Fix-Catch invalid google recaptcha v3 key error (#6034) * Handle invalid google recaptcha v3 key --- .../designSystems/blueprint/ButtonComponent.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/client/src/components/designSystems/blueprint/ButtonComponent.tsx b/app/client/src/components/designSystems/blueprint/ButtonComponent.tsx index 367c368a46..a367e200fd 100644 --- a/app/client/src/components/designSystems/blueprint/ButtonComponent.tsx +++ b/app/client/src/components/designSystems/blueprint/ButtonComponent.tsx @@ -240,12 +240,7 @@ function RecaptchaV3Component( ) { // Check if a string is a valid JSON string const checkValidJson = (inputString: string): boolean => { - try { - JSON.parse(inputString); - return true; - } catch (err) { - return false; - } + return !inputString.includes('"'); }; const handleBtnClick = (event: React.MouseEvent) => { @@ -278,11 +273,9 @@ function RecaptchaV3Component( }; let validGoogleRecaptchaKey = props.googleRecaptchaKey; - - if (validGoogleRecaptchaKey && checkValidJson(validGoogleRecaptchaKey)) { + if (validGoogleRecaptchaKey && !checkValidJson(validGoogleRecaptchaKey)) { validGoogleRecaptchaKey = undefined; } - const status = useScript( `https://www.google.com/recaptcha/api.js?render=${validGoogleRecaptchaKey}`, );