From 1142561532c66295ac172d4c9837a6f35e5d4b95 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Thu, 21 May 2015 09:21:47 +0100 Subject: [PATCH] Improve config-parser JSON handling closes #5294 This improves a hack for parsing JSON to be more robust. Now attempt to parse JSON, and if it's not possible it will fallback to treating the value is a string, reverting the behaviour to what it would have been if we didn't have JSON parsing here. --- ghost/admin/app/utils/config-parser.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ghost/admin/app/utils/config-parser.js b/ghost/admin/app/utils/config-parser.js index 629ed73ffb..cb2a97ecc0 100644 --- a/ghost/admin/app/utils/config-parser.js +++ b/ghost/admin/app/utils/config-parser.js @@ -12,7 +12,12 @@ var isNumeric = function (num) { } else if (isNumeric(val)) { return +val; } else if (val.indexOf('{') === 0) { - return JSON.parse(val); + try { + return JSON.parse(val); + } catch (e) { + /*jshint unused:false */ + return val; + } } else { return val; }