diff --git a/boot/boot.js b/boot/boot.js index f4add931b..fada4014d 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1469,8 +1469,40 @@ $tw.modules.define("$:/boot/tiddlerdeserializer/html","tiddlerdeserializer",{ }); $tw.modules.define("$:/boot/tiddlerdeserializer/json","tiddlerdeserializer",{ "application/json": function(text,fields) { - var data = JSON.parse(text); - return $tw.utils.isArray(data) ? data : [data]; + var isTiddlerValid = function(data) { + // Not valid if it's not an object with a title property + if(typeof(data) !== "object" || !$tw.utils.hop(data,"title")) { + return false; + } + for(var f in data) { + if($tw.utils.hop(data,f)) { + // Check field name doesn't contain whitespace or control characters + if(typeof(data[f]) !== "string" || /[\x00-\x1F\s]/.test(f)) { + return false; + } + } + } + return true; + }, + isTiddlerArrayValid = function(data) { + for(var t=0; t