Released v5.9.1
This commit is contained in:
parent
a00ec59241
commit
2046d98936
|
@ -3,6 +3,14 @@
|
||||||
https://github.com/josdejong/jsoneditor
|
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
|
## 2017-07-10, version 5.9.0
|
||||||
|
|
||||||
- Implemented support for JSON schema references `$ref`, see #302.
|
- Implemented support for JSON schema references `$ref`, see #302.
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
* Copyright (c) 2011-2017 Jos de Jong, http://jsoneditoronline.org
|
* Copyright (c) 2011-2017 Jos de Jong, http://jsoneditoronline.org
|
||||||
*
|
*
|
||||||
* @author Jos de Jong, <wjosdejong@gmail.com>
|
* @author Jos de Jong, <wjosdejong@gmail.com>
|
||||||
* @version 5.9.0
|
* @version 5.9.1
|
||||||
* @date 2017-07-10
|
* @date 2017-07-13
|
||||||
*/
|
*/
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
if(typeof exports === 'object' && typeof module === 'object')
|
||||||
|
@ -704,7 +704,16 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
* @param {String} jsonText
|
* @param {String} jsonText
|
||||||
*/
|
*/
|
||||||
treemode.setText = function(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];
|
jsString = match[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var controlChars = {
|
||||||
|
'\b': '\\b',
|
||||||
|
'\f': '\\f',
|
||||||
|
'\n': '\\n',
|
||||||
|
'\r': '\\r',
|
||||||
|
'\t': '\\t'
|
||||||
|
};
|
||||||
|
|
||||||
// helper functions to get the current/prev/next character
|
// helper functions to get the current/prev/next character
|
||||||
function curr () { return jsString.charAt(i); }
|
function curr () { return jsString.charAt(i); }
|
||||||
function next() { return jsString.charAt(i + 1); }
|
function next() { return jsString.charAt(i + 1); }
|
||||||
|
@ -2190,6 +2207,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
chars.push('\\');
|
chars.push('\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replace unescaped control characters with escaped ones
|
||||||
|
if (controlChars.hasOwnProperty(c)) {
|
||||||
|
chars.push(controlChars[c])
|
||||||
|
i++;
|
||||||
|
c = curr();
|
||||||
|
}
|
||||||
|
|
||||||
// handle escape character
|
// handle escape character
|
||||||
if (c === '\\') {
|
if (c === '\\') {
|
||||||
i++;
|
i++;
|
||||||
|
@ -2200,8 +2224,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
chars.push('\\');
|
chars.push('\\');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chars.push(c);
|
|
||||||
|
|
||||||
|
chars.push(c);
|
||||||
i++;
|
i++;
|
||||||
c = curr();
|
c = curr();
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -24,8 +24,8 @@
|
||||||
* Copyright (c) 2011-2017 Jos de Jong, http://jsoneditoronline.org
|
* Copyright (c) 2011-2017 Jos de Jong, http://jsoneditoronline.org
|
||||||
*
|
*
|
||||||
* @author Jos de Jong, <wjosdejong@gmail.com>
|
* @author Jos de Jong, <wjosdejong@gmail.com>
|
||||||
* @version 5.9.0
|
* @version 5.9.1
|
||||||
* @date 2017-07-10
|
* @date 2017-07-13
|
||||||
*/
|
*/
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
if(typeof exports === 'object' && typeof module === 'object')
|
||||||
|
@ -8680,7 +8680,16 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
* @param {String} jsonText
|
* @param {String} jsonText
|
||||||
*/
|
*/
|
||||||
treemode.setText = function(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];
|
jsString = match[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var controlChars = {
|
||||||
|
'\b': '\\b',
|
||||||
|
'\f': '\\f',
|
||||||
|
'\n': '\\n',
|
||||||
|
'\r': '\\r',
|
||||||
|
'\t': '\\t'
|
||||||
|
};
|
||||||
|
|
||||||
// helper functions to get the current/prev/next character
|
// helper functions to get the current/prev/next character
|
||||||
function curr () { return jsString.charAt(i); }
|
function curr () { return jsString.charAt(i); }
|
||||||
function next() { return jsString.charAt(i + 1); }
|
function next() { return jsString.charAt(i + 1); }
|
||||||
|
@ -10166,6 +10183,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
chars.push('\\');
|
chars.push('\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replace unescaped control characters with escaped ones
|
||||||
|
if (controlChars.hasOwnProperty(c)) {
|
||||||
|
chars.push(controlChars[c])
|
||||||
|
i++;
|
||||||
|
c = curr();
|
||||||
|
}
|
||||||
|
|
||||||
// handle escape character
|
// handle escape character
|
||||||
if (c === '\\') {
|
if (c === '\\') {
|
||||||
i++;
|
i++;
|
||||||
|
@ -10176,8 +10200,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
chars.push('\\');
|
chars.push('\\');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chars.push(c);
|
|
||||||
|
|
||||||
|
chars.push(c);
|
||||||
i++;
|
i++;
|
||||||
c = curr();
|
c = curr();
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "jsoneditor",
|
"name": "jsoneditor",
|
||||||
"version": "5.9.0",
|
"version": "5.9.1",
|
||||||
"main": "./index",
|
"main": "./index",
|
||||||
"description": "A web-based tool to view, edit, format, and validate JSON",
|
"description": "A web-based tool to view, edit, format, and validate JSON",
|
||||||
"tags": [
|
"tags": [
|
||||||
|
|
|
@ -216,7 +216,16 @@ treemode.getText = function() {
|
||||||
* @param {String} jsonText
|
* @param {String} jsonText
|
||||||
*/
|
*/
|
||||||
treemode.setText = function(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
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,6 +42,14 @@ exports.sanitize = function (jsString) {
|
||||||
jsString = match[3];
|
jsString = match[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var controlChars = {
|
||||||
|
'\b': '\\b',
|
||||||
|
'\f': '\\f',
|
||||||
|
'\n': '\\n',
|
||||||
|
'\r': '\\r',
|
||||||
|
'\t': '\\t'
|
||||||
|
};
|
||||||
|
|
||||||
// helper functions to get the current/prev/next character
|
// helper functions to get the current/prev/next character
|
||||||
function curr () { return jsString.charAt(i); }
|
function curr () { return jsString.charAt(i); }
|
||||||
function next() { return jsString.charAt(i + 1); }
|
function next() { return jsString.charAt(i + 1); }
|
||||||
|
@ -90,6 +98,13 @@ exports.sanitize = function (jsString) {
|
||||||
chars.push('\\');
|
chars.push('\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replace unescaped control characters with escaped ones
|
||||||
|
if (controlChars.hasOwnProperty(c)) {
|
||||||
|
chars.push(controlChars[c])
|
||||||
|
i++;
|
||||||
|
c = curr();
|
||||||
|
}
|
||||||
|
|
||||||
// handle escape character
|
// handle escape character
|
||||||
if (c === '\\') {
|
if (c === '\\') {
|
||||||
i++;
|
i++;
|
||||||
|
@ -100,8 +115,8 @@ exports.sanitize = function (jsString) {
|
||||||
chars.push('\\');
|
chars.push('\\');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chars.push(c);
|
|
||||||
|
|
||||||
|
chars.push(c);
|
||||||
i++;
|
i++;
|
||||||
c = curr();
|
c = curr();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue