1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-28 11:00:27 +00:00

Trap JSON syntax errors during import

Fixes #2609
This commit is contained in:
Jermolene 2016-10-13 14:16:55 +01:00
parent da298f037d
commit 892a1f560e

View File

@ -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<incoming.length; t++) {
var incomingFields = incoming[t],