From 38c32233f6e046d4fe0986b424889006c7b155f4 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 3 Jul 2024 07:25:51 -0700 Subject: [PATCH] Enhancement: strip whitespace when checking JSON (#3706) --- src/utils/proxy/validate-widget-data.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/proxy/validate-widget-data.js b/src/utils/proxy/validate-widget-data.js index 343dbb854..a1e41acf6 100644 --- a/src/utils/proxy/validate-widget-data.js +++ b/src/utils/proxy/validate-widget-data.js @@ -10,8 +10,13 @@ export default function validateWidgetData(widget, endpoint, data) { try { dataParsed = JSON.parse(data); } catch (e) { - error = e; - valid = false; + try { + // try once more stripping whitespace + dataParsed = JSON.parse(data.toString().replace(/\s/g, "")); + } catch (e2) { + error = e || e2; + valid = false; + } } }