Released v5.9.1

This commit is contained in:
jos 2017-07-13 20:19:01 +02:00
parent a00ec59241
commit 2046d98936
10 changed files with 103 additions and 23 deletions

View File

@ -3,6 +3,14 @@
https://github.com/josdejong/jsoneditor
## 2017-07-13, version 5.9.1
- `setText` method of tree mode now automatically sanitizes JSON input
when needed.
- Fixed #430: automatically fix unescaped control characters in
JSON input.
## 2017-07-10, version 5.9.0
- Implemented support for JSON schema references `$ref`, see #302.

View File

@ -24,8 +24,8 @@
* Copyright (c) 2011-2017 Jos de Jong, http://jsoneditoronline.org
*
* @author Jos de Jong, <wjosdejong@gmail.com>
* @version 5.9.0
* @date 2017-07-10
* @version 5.9.1
* @date 2017-07-13
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
@ -704,7 +704,16 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {String} jsonText
*/
treemode.setText = function(jsonText) {
this.set(util.parse(jsonText));
try {
this.set(util.parse(jsonText)); // this can throw an error
}
catch (err) {
// try to sanitize json, replace JavaScript notation with JSON notation
var sanitizedJsonText = util.sanitize(jsonText);
// try to parse again
this.set(util.parse(sanitizedJsonText)); // this can throw an error
}
};
/**
@ -2142,6 +2151,14 @@ return /******/ (function(modules) { // webpackBootstrap
jsString = match[3];
}
var controlChars = {
'\b': '\\b',
'\f': '\\f',
'\n': '\\n',
'\r': '\\r',
'\t': '\\t'
};
// helper functions to get the current/prev/next character
function curr () { return jsString.charAt(i); }
function next() { return jsString.charAt(i + 1); }
@ -2190,6 +2207,13 @@ return /******/ (function(modules) { // webpackBootstrap
chars.push('\\');
}
// replace unescaped control characters with escaped ones
if (controlChars.hasOwnProperty(c)) {
chars.push(controlChars[c])
i++;
c = curr();
}
// handle escape character
if (c === '\\') {
i++;
@ -2200,8 +2224,8 @@ return /******/ (function(modules) { // webpackBootstrap
chars.push('\\');
}
}
chars.push(c);
chars.push(c);
i++;
c = curr();
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

32
dist/jsoneditor.js vendored
View File

@ -24,8 +24,8 @@
* Copyright (c) 2011-2017 Jos de Jong, http://jsoneditoronline.org
*
* @author Jos de Jong, <wjosdejong@gmail.com>
* @version 5.9.0
* @date 2017-07-10
* @version 5.9.1
* @date 2017-07-13
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
@ -8680,7 +8680,16 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {String} jsonText
*/
treemode.setText = function(jsonText) {
this.set(util.parse(jsonText));
try {
this.set(util.parse(jsonText)); // this can throw an error
}
catch (err) {
// try to sanitize json, replace JavaScript notation with JSON notation
var sanitizedJsonText = util.sanitize(jsonText);
// try to parse again
this.set(util.parse(sanitizedJsonText)); // this can throw an error
}
};
/**
@ -10118,6 +10127,14 @@ return /******/ (function(modules) { // webpackBootstrap
jsString = match[3];
}
var controlChars = {
'\b': '\\b',
'\f': '\\f',
'\n': '\\n',
'\r': '\\r',
'\t': '\\t'
};
// helper functions to get the current/prev/next character
function curr () { return jsString.charAt(i); }
function next() { return jsString.charAt(i + 1); }
@ -10166,6 +10183,13 @@ return /******/ (function(modules) { // webpackBootstrap
chars.push('\\');
}
// replace unescaped control characters with escaped ones
if (controlChars.hasOwnProperty(c)) {
chars.push(controlChars[c])
i++;
c = curr();
}
// handle escape character
if (c === '\\') {
i++;
@ -10176,8 +10200,8 @@ return /******/ (function(modules) { // webpackBootstrap
chars.push('\\');
}
}
chars.push(c);
chars.push(c);
i++;
c = curr();
}

2
dist/jsoneditor.map vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "jsoneditor",
"version": "5.9.0",
"version": "5.9.1",
"main": "./index",
"description": "A web-based tool to view, edit, format, and validate JSON",
"tags": [

View File

@ -216,7 +216,16 @@ treemode.getText = function() {
* @param {String} jsonText
*/
treemode.setText = function(jsonText) {
this.set(util.parse(jsonText));
try {
this.set(util.parse(jsonText)); // this can throw an error
}
catch (err) {
// try to sanitize json, replace JavaScript notation with JSON notation
var sanitizedJsonText = util.sanitize(jsonText);
// try to parse again
this.set(util.parse(sanitizedJsonText)); // this can throw an error
}
};
/**

View File

@ -42,6 +42,14 @@ exports.sanitize = function (jsString) {
jsString = match[3];
}
var controlChars = {
'\b': '\\b',
'\f': '\\f',
'\n': '\\n',
'\r': '\\r',
'\t': '\\t'
};
// helper functions to get the current/prev/next character
function curr () { return jsString.charAt(i); }
function next() { return jsString.charAt(i + 1); }
@ -90,6 +98,13 @@ exports.sanitize = function (jsString) {
chars.push('\\');
}
// replace unescaped control characters with escaped ones
if (controlChars.hasOwnProperty(c)) {
chars.push(controlChars[c])
i++;
c = curr();
}
// handle escape character
if (c === '\\') {
i++;
@ -100,8 +115,8 @@ exports.sanitize = function (jsString) {
chars.push('\\');
}
}
chars.push(c);
chars.push(c);
i++;
c = curr();
}