@json-editor/json-editor 2.15.2 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/CONTRIBUTING.md +10 -0
- package/README.md +11 -0
- package/dist/jsoneditor.js +1 -1
- package/dist/jsoneditor.js.LICENSE.txt +1 -1
- package/dist/nonmin/jsoneditor.js +20 -2
- package/dist/nonmin/jsoneditor.js.map +1 -1
- package/docs/form-submission.html +1 -1
- package/docs/index.html +18 -0
- package/package.json +1 -1
- package/src/editor.js +15 -1
- package/src/editors/hidden.js +1 -0
- package/src/editors/multiselect.js +1 -0
- package/src/editors/string.js +2 -0
- package/src/editors/uuid.js +1 -0
- package/tests/codeceptjs/editors/purify_test.js +26 -0
- package/tests/codeceptjs/issues/issue-gh-1559_test.js +15 -0
- package/tests/docker-compose-local.yml +3 -2
- package/tests/pages/issues/issue-gh-1559.html +68 -0
- package/tests/pages/purify.html +66 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* * @name JSON Editor
|
|
4
4
|
* * @description JSON Schema Based Editor
|
|
5
5
|
* * This library is the continuation of jdorn's great work (see also https://github.com/jdorn/json-editor/issues/800)
|
|
6
|
-
* * @version "2.
|
|
6
|
+
* * @version "2.16.0"
|
|
7
7
|
* * @author Jeremy Dorn
|
|
8
8
|
* * @see https://github.com/jdorn/json-editor/
|
|
9
9
|
* * @see https://github.com/json-editor/json-editor
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* * @name JSON Editor
|
|
4
4
|
* * @description JSON Schema Based Editor
|
|
5
5
|
* * This library is the continuation of jdorn's great work (see also https://github.com/jdorn/json-editor/issues/800)
|
|
6
|
-
* * @version "2.
|
|
6
|
+
* * @version "2.16.0"
|
|
7
7
|
* * @author Jeremy Dorn
|
|
8
8
|
* * @see https://github.com/jdorn/json-editor/
|
|
9
9
|
* * @see https://github.com/json-editor/json-editor
|
|
@@ -844,7 +844,7 @@ var AbstractEditor = /*#__PURE__*/function () {
|
|
|
844
844
|
}
|
|
845
845
|
var editor = this.jsoneditor.getEditor(path);
|
|
846
846
|
var value = editor ? editor.getValue() : undefined;
|
|
847
|
-
if (!editor || !editor.dependenciesFulfilled ||
|
|
847
|
+
if (!editor || !editor.dependenciesFulfilled || value === undefined || value === null) {
|
|
848
848
|
this.dependenciesFulfilled = false;
|
|
849
849
|
} else if (Array.isArray(choices)) {
|
|
850
850
|
this.dependenciesFulfilled = choices.some(function (choice) {
|
|
@@ -1174,6 +1174,19 @@ var AbstractEditor = /*#__PURE__*/function () {
|
|
|
1174
1174
|
}
|
|
1175
1175
|
}
|
|
1176
1176
|
}
|
|
1177
|
+
}, {
|
|
1178
|
+
key: "purify",
|
|
1179
|
+
value: function purify(val) {
|
|
1180
|
+
if (typeof val !== 'string') {
|
|
1181
|
+
return val;
|
|
1182
|
+
}
|
|
1183
|
+
if (window.DOMPurify) {
|
|
1184
|
+
val = window.DOMPurify.sanitize(val);
|
|
1185
|
+
} else {
|
|
1186
|
+
val = this.cleanText(val);
|
|
1187
|
+
}
|
|
1188
|
+
return val;
|
|
1189
|
+
}
|
|
1177
1190
|
}, {
|
|
1178
1191
|
key: "getHeaderText",
|
|
1179
1192
|
value: function getHeaderText(titleOnly) {
|
|
@@ -5563,6 +5576,7 @@ var HiddenEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
5563
5576
|
}, {
|
|
5564
5577
|
key: "sanitize",
|
|
5565
5578
|
value: function sanitize(value) {
|
|
5579
|
+
value = this.purify(value);
|
|
5566
5580
|
return value;
|
|
5567
5581
|
}
|
|
5568
5582
|
|
|
@@ -7120,6 +7134,7 @@ var MultiSelectEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
7120
7134
|
}, {
|
|
7121
7135
|
key: "sanitize",
|
|
7122
7136
|
value: function sanitize(value) {
|
|
7137
|
+
value = this.purify(value);
|
|
7123
7138
|
if (this.schema.items.type === 'boolean') return !!value;else if (this.schema.items.type === 'number') return 1 * value || 0;else if (this.schema.items.type === 'integer') return Math.floor(value * 1 || 0);
|
|
7124
7139
|
return "".concat(value);
|
|
7125
7140
|
}
|
|
@@ -11252,6 +11267,7 @@ var StringEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
11252
11267
|
}, {
|
|
11253
11268
|
key: "setValue",
|
|
11254
11269
|
value: function setValue(value, initial, fromTemplate) {
|
|
11270
|
+
value = this.purify(value);
|
|
11255
11271
|
value = this.applyConstFilter(value);
|
|
11256
11272
|
if (this.template && !fromTemplate) return;
|
|
11257
11273
|
if (!this.shouldBeUnset() && (value === null || typeof value === 'undefined')) value = '';else if (_typeof(value) === 'object') value = JSON.stringify(value);else if (!this.shouldBeUnset() && typeof value !== 'string') value = "".concat(value);
|
|
@@ -11580,6 +11596,7 @@ var StringEditor = /*#__PURE__*/function (_AbstractEditor) {
|
|
|
11580
11596
|
}, {
|
|
11581
11597
|
key: "sanitize",
|
|
11582
11598
|
value: function sanitize(value) {
|
|
11599
|
+
value = this.purify(value);
|
|
11583
11600
|
return value;
|
|
11584
11601
|
}
|
|
11585
11602
|
|
|
@@ -12856,6 +12873,7 @@ var UuidEditor = /*#__PURE__*/function (_StringEditor) {
|
|
|
12856
12873
|
}, {
|
|
12857
12874
|
key: "sanitize",
|
|
12858
12875
|
value: function sanitize(value) {
|
|
12876
|
+
value = this.purify(value);
|
|
12859
12877
|
if (!this.testUuid(value)) value = this.uuid;
|
|
12860
12878
|
return value;
|
|
12861
12879
|
}
|