@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.
@@ -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.15.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.15.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 || !value) {
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
  }