From 892a1f560ebbc986986242730593f376ec386519 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 13 Oct 2016 14:16:55 +0100 Subject: [PATCH] Trap JSON syntax errors during import Fixes #2609 --- core/modules/deserializers.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/modules/deserializers.js b/core/modules/deserializers.js index 00815f831..16f5a373f 100644 --- a/core/modules/deserializers.js +++ b/core/modules/deserializers.js @@ -72,8 +72,16 @@ exports["application/x-tiddler-html-div"] = function(text,fields) { }; exports["application/json"] = function(text,fields) { - var incoming = JSON.parse(text), + var incoming, results = []; + try { + incoming = JSON.parse(text); + } catch(e) { + incoming = [{ + title: "JSON error: " + e, + text: "" + }] + } if($tw.utils.isArray(incoming)) { for(var t=0; t