diff --git a/api/setup/saveWizard.cfm b/api/setup/saveWizard.cfm index dcc1bbd..6bd1b1a 100644 --- a/api/setup/saveWizard.cfm +++ b/api/setup/saveWizard.cfm @@ -145,7 +145,21 @@ try { // Clean control characters that Lucee's JSON parser can't handle requestBody = reReplace(requestBody, "[\x00-\x08\x0B\x0C\x0E-\x1F]", "", "all"); - data = deserializeJSON(requestBody); + try { + data = deserializeJSON(requestBody); + } catch (any jsonErr) { + // Log snippet around error for debugging + nums = reMatch("\d+", jsonErr.message); + errorPos = 0; + for (n in nums) { if (val(n) > 1000) { errorPos = val(n); break; } } + if (errorPos > 0) { + snippet = mid(requestBody, max(1, errorPos - 100), 250); + arrayAppend(response.errors, "JSON parse failed near position #errorPos#: [#snippet#]"); + } + arrayAppend(response.errors, jsonErr.message); + writeOutput(serializeJSON(response)); + abort; + } businessId = structKeyExists(data, "businessId") ? val(data.businessId) : 0; userId = structKeyExists(data, "userId") ? val(data.userId) : 0;