@reltio/components 1.4.1252 → 1.4.1254

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.
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ attributes: {
3
+ '*': string[];
4
+ img: string[];
5
+ link: string[];
6
+ iframe: string[];
7
+ a: string[];
8
+ };
9
+ tags: string[];
10
+ };
11
+ export default _default;
@@ -0,0 +1,340 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
+ to[j] = from[i];
5
+ return to;
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ var defaultAttributes = [
9
+ 'accent-height',
10
+ 'accumulate',
11
+ 'additive',
12
+ 'alignment-baseline',
13
+ 'allowReorder',
14
+ 'alphabetic',
15
+ 'amplitude',
16
+ 'arabic-form',
17
+ 'ascent',
18
+ 'attributeName',
19
+ 'attributeType',
20
+ 'autoReverse',
21
+ 'azimuth',
22
+ 'baseFrequency',
23
+ 'baseline-shift',
24
+ 'baseProfile',
25
+ 'bbox',
26
+ 'begin',
27
+ 'bias',
28
+ 'by',
29
+ 'calcMode',
30
+ 'cap-height',
31
+ 'class',
32
+ 'clip',
33
+ 'clipPathUnits',
34
+ 'clip-path',
35
+ 'clip-rule',
36
+ 'color',
37
+ 'color-interpolation',
38
+ 'color-interpolation-filters',
39
+ 'color-profile',
40
+ 'color-rendering',
41
+ 'contentScriptType',
42
+ 'contentStyleType',
43
+ 'cursor',
44
+ 'cx',
45
+ 'cy',
46
+ 'd',
47
+ 'decelerate',
48
+ 'descent',
49
+ 'diffuseConstant',
50
+ 'direction',
51
+ 'display',
52
+ 'divisor',
53
+ 'dominant-baseline',
54
+ 'dur',
55
+ 'dx',
56
+ 'dy',
57
+ 'edgeMode',
58
+ 'elevation',
59
+ 'enable-background',
60
+ 'end',
61
+ 'exponent',
62
+ 'externalResourcesRequired',
63
+ 'fill',
64
+ 'fill-opacity',
65
+ 'fill-rule',
66
+ 'filter',
67
+ 'filterRes',
68
+ 'filterUnits',
69
+ 'flood-color',
70
+ 'flood-opacity',
71
+ 'font-family',
72
+ 'font-size',
73
+ 'font-size-adjust',
74
+ 'font-stretch',
75
+ 'font-style',
76
+ 'font-variant',
77
+ 'font-weight',
78
+ 'format',
79
+ 'from',
80
+ 'fx',
81
+ 'fy',
82
+ 'g1',
83
+ 'g2',
84
+ 'glyph-name',
85
+ 'glyph-orientation-horizontal',
86
+ 'glyph-orientation-vertical',
87
+ 'glyphRef',
88
+ 'gradientTransform',
89
+ 'gradientUnits',
90
+ 'hanging',
91
+ 'height',
92
+ 'horiz-adv-x',
93
+ 'horiz-origin-x',
94
+ 'id',
95
+ 'ideographic',
96
+ 'image-rendering',
97
+ 'in',
98
+ 'in2',
99
+ 'intercept',
100
+ 'k',
101
+ 'k1',
102
+ 'k2',
103
+ 'k3',
104
+ 'k4',
105
+ 'kernelMatrix',
106
+ 'kernelUnitLength',
107
+ 'kerning',
108
+ 'keyPoints',
109
+ 'keySplines',
110
+ 'keyTimes',
111
+ 'lang',
112
+ 'lengthAdjust',
113
+ 'letter-spacing',
114
+ 'lighting-color',
115
+ 'limitingConeAngle',
116
+ 'local',
117
+ 'marker-end',
118
+ 'marker-mid',
119
+ 'marker-start',
120
+ 'markerHeight',
121
+ 'markerUnits',
122
+ 'markerWidth',
123
+ 'mask',
124
+ 'maskContentUnits',
125
+ 'maskUnits',
126
+ 'mathematical',
127
+ 'max',
128
+ 'media',
129
+ 'method',
130
+ 'min',
131
+ 'mode',
132
+ 'name',
133
+ 'numOctaves',
134
+ 'offset',
135
+ 'opacity',
136
+ 'operator',
137
+ 'order',
138
+ 'orient',
139
+ 'orientation',
140
+ 'origin',
141
+ 'overflow',
142
+ 'overline-position',
143
+ 'overline-thickness',
144
+ 'panose-1',
145
+ 'paint-order',
146
+ 'path',
147
+ 'pathLength',
148
+ 'patternContentUnits',
149
+ 'patternTransform',
150
+ 'patternUnits',
151
+ 'pointer-events',
152
+ 'points',
153
+ 'pointsAtX',
154
+ 'pointsAtY',
155
+ 'pointsAtZ',
156
+ 'preserveAlpha',
157
+ 'preserveAspectRatio',
158
+ 'primitiveUnits',
159
+ 'r',
160
+ 'radius',
161
+ 'refX',
162
+ 'refY',
163
+ 'rendering-intent',
164
+ 'repeatCount',
165
+ 'repeatDur',
166
+ 'requiredExtensions',
167
+ 'requiredFeatures',
168
+ 'restart',
169
+ 'result',
170
+ 'rotate',
171
+ 'rx',
172
+ 'ry',
173
+ 'scale',
174
+ 'seed',
175
+ 'shape-rendering',
176
+ 'slope',
177
+ 'spacing',
178
+ 'specularConstant',
179
+ 'specularExponent',
180
+ 'speed',
181
+ 'spreadMethod',
182
+ 'startOffset',
183
+ 'stdDeviation',
184
+ 'stemh',
185
+ 'stemv',
186
+ 'stitchTiles',
187
+ 'stop-color',
188
+ 'stop-opacity',
189
+ 'strikethrough-position',
190
+ 'strikethrough-thickness',
191
+ 'string',
192
+ 'stroke',
193
+ 'stroke-dasharray',
194
+ 'stroke-dashoffset',
195
+ 'stroke-linecap',
196
+ 'stroke-linejoin',
197
+ 'stroke-miterlimit',
198
+ 'stroke-opacity',
199
+ 'stroke-width',
200
+ 'style',
201
+ 'surfaceScale',
202
+ 'systemLanguage',
203
+ 'tableValues',
204
+ 'target',
205
+ 'targetX',
206
+ 'targetY',
207
+ 'text-anchor',
208
+ 'text-decoration',
209
+ 'text-rendering',
210
+ 'textLength',
211
+ 'to',
212
+ 'transform',
213
+ 'type',
214
+ 'u1',
215
+ 'u2',
216
+ 'underline-position',
217
+ 'underline-thickness',
218
+ 'unicode',
219
+ 'unicode-bidi',
220
+ 'unicode-range',
221
+ 'units-per-em',
222
+ 'v-alphabetic',
223
+ 'v-hanging',
224
+ 'v-ideographic',
225
+ 'v-mathematical',
226
+ 'values',
227
+ 'version',
228
+ 'vert-adv-y',
229
+ 'vert-origin-x',
230
+ 'vert-origin-y',
231
+ 'viewBox',
232
+ 'viewTarget',
233
+ 'visibility',
234
+ 'width',
235
+ 'widths',
236
+ 'word-spacing',
237
+ 'writing-mode',
238
+ 'x',
239
+ 'x-height',
240
+ 'x1',
241
+ 'x2',
242
+ 'xChannelSelector',
243
+ 'y',
244
+ 'y1',
245
+ 'y2',
246
+ 'yChannelSelector',
247
+ 'z',
248
+ 'zoomAndPan'
249
+ ];
250
+ var defaultTags = [
251
+ 'animate',
252
+ 'animateColor',
253
+ 'animateMotion',
254
+ 'animateTransform',
255
+ 'mpath',
256
+ 'set',
257
+ 'circle',
258
+ 'ellipse',
259
+ 'line',
260
+ 'polygon',
261
+ 'polyline',
262
+ 'rect',
263
+ 'defs',
264
+ 'glyph',
265
+ 'g',
266
+ 'marker',
267
+ 'mask',
268
+ 'missing-glyph',
269
+ 'pattern',
270
+ 'svg',
271
+ 'switch',
272
+ 'symbol',
273
+ 'font',
274
+ 'font-face',
275
+ 'font-face-format',
276
+ 'font-face-name',
277
+ 'font-face-src',
278
+ 'font-face-uri',
279
+ 'hkern',
280
+ 'vkern',
281
+ 'linearGradient',
282
+ 'radialGradient',
283
+ 'stop',
284
+ 'circle',
285
+ 'ellipse',
286
+ 'image',
287
+ 'line',
288
+ 'path',
289
+ 'polygon',
290
+ 'polyline',
291
+ 'rect',
292
+ 'text',
293
+ 'use',
294
+ 'feDistantLight',
295
+ 'fePointLight',
296
+ 'feSpotLight',
297
+ 'circle',
298
+ 'ellipse',
299
+ 'line',
300
+ 'path',
301
+ 'polygon',
302
+ 'polyline',
303
+ 'rect',
304
+ 'defs',
305
+ 'g',
306
+ 'svg',
307
+ 'symbol',
308
+ 'use',
309
+ 'altGlyph',
310
+ 'altGlyphDef',
311
+ 'altGlyphItem',
312
+ 'glyph',
313
+ 'glyphRef',
314
+ 'textPath',
315
+ 'text',
316
+ 'tref',
317
+ 'tspan',
318
+ 'altGlyph',
319
+ 'textPath',
320
+ 'tref',
321
+ 'tspan',
322
+ 'clipPath',
323
+ 'color-profile',
324
+ 'cursor',
325
+ 'filter',
326
+ 'foreignObject',
327
+ 'script',
328
+ 'style',
329
+ 'view'
330
+ ];
331
+ exports.default = {
332
+ attributes: {
333
+ '*': __spreadArray(__spreadArray([], defaultAttributes), ['ui-actions', 'ui-tooltip']),
334
+ img: ['src', 'srcset', 'alt', 'title', 'loading'],
335
+ link: ['href', 'rel'],
336
+ iframe: ['src'],
337
+ a: ['href']
338
+ },
339
+ tags: __spreadArray(__spreadArray([], defaultTags), ['a', 'link', 'input', 'button', 'iframe', 'img'])
340
+ };
@@ -37,6 +37,7 @@ var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
37
37
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
38
38
  var ramda_1 = require("ramda");
39
39
  var workflow_1 = require("../../components/workflow");
40
+ var useHtmlSanitizer_1 = require("../useHtmlSanitizer");
40
41
  var contexts_1 = require("../../contexts");
41
42
  var API_1 = require("./API");
42
43
  var helpers_1 = require("./helpers");
@@ -54,6 +55,7 @@ var useAPI = function (config) {
54
55
  var requestListeners = react_1.useRef({});
55
56
  var responseListeners = react_1.useRef({});
56
57
  var dispatch = react_redux_1.useDispatch();
58
+ var sanitizeHtml = useHtmlSanitizer_1.useHtmlSanitizer();
57
59
  var uiPath = react_redux_1.useSelector(mdm_module_1.default.selectors.getUIPath);
58
60
  var tenant = react_redux_1.useSelector(mdm_module_1.default.selectors.getTenant);
59
61
  var workerUrl = helpers_1.getWorkerURL(uiPath, tenant);
@@ -82,16 +84,17 @@ var useAPI = function (config) {
82
84
  if (task) {
83
85
  switch (task.action) {
84
86
  case mdm_sdk_1.CustomAction.SET_HTML: {
87
+ var sanitizedHtml = sanitizeHtml(task.params.html);
85
88
  if (task.params.id) {
86
89
  var elem = document.getElementById(task.params.id);
87
- elem.innerHTML = task.params.html;
90
+ elem.innerHTML = sanitizedHtml;
88
91
  }
89
- else if (innerText !== task.params.html) {
90
- innerText = task.params.html;
92
+ else if (innerText !== sanitizedHtml) {
93
+ innerText = sanitizedHtml;
91
94
  helpers_1.resetHtml({
92
95
  worker: worker,
93
96
  setTooltip: setTooltip,
94
- html: task.params.html,
97
+ html: sanitizedHtml,
95
98
  innerText: innerText,
96
99
  setListenersToReset: setListenersToReset,
97
100
  setHtml: setHtml
@@ -100,11 +103,12 @@ var useAPI = function (config) {
100
103
  break;
101
104
  }
102
105
  case mdm_sdk_1.CustomAction.SHOW_POPUP: {
103
- popupText = task.params;
106
+ var sanitizedPopup = sanitizeHtml(task.params);
107
+ popupText = sanitizedPopup;
104
108
  helpers_1.resetHtml({
105
109
  worker: worker,
106
110
  setTooltip: setTooltip,
107
- html: task.params,
111
+ html: sanitizedPopup,
108
112
  innerText: popupText,
109
113
  setListenersToReset: setPopupListenersToReset,
110
114
  setHtml: setPopup
@@ -0,0 +1 @@
1
+ export declare const useHtmlSanitizer: () => (html: string) => string;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.useHtmlSanitizer = void 0;
18
+ var sanitize_html_1 = __importDefault(require("sanitize-html"));
19
+ var sanitizerOptions_1 = __importDefault(require("./helpers/sanitizerOptions"));
20
+ var useHtmlSanitizer = function () {
21
+ var _a = sanitize_html_1.default.defaults, allowedAttributes = _a.allowedAttributes, allowedTags = _a.allowedTags;
22
+ var attributes = sanitizerOptions_1.default.attributes, tags = sanitizerOptions_1.default.tags;
23
+ var options = {
24
+ allowedTags: allowedTags.concat(tags),
25
+ allowedAttributes: __assign(__assign({}, allowedAttributes), attributes),
26
+ allowVulnerableTags: true
27
+ };
28
+ return function (html) { return sanitize_html_1.default(html, options); };
29
+ };
30
+ exports.useHtmlSanitizer = useHtmlSanitizer;
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ attributes: {
3
+ '*': string[];
4
+ img: string[];
5
+ link: string[];
6
+ iframe: string[];
7
+ a: string[];
8
+ };
9
+ tags: string[];
10
+ };
11
+ export default _default;
@@ -0,0 +1,338 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
2
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
3
+ to[j] = from[i];
4
+ return to;
5
+ };
6
+ var defaultAttributes = [
7
+ 'accent-height',
8
+ 'accumulate',
9
+ 'additive',
10
+ 'alignment-baseline',
11
+ 'allowReorder',
12
+ 'alphabetic',
13
+ 'amplitude',
14
+ 'arabic-form',
15
+ 'ascent',
16
+ 'attributeName',
17
+ 'attributeType',
18
+ 'autoReverse',
19
+ 'azimuth',
20
+ 'baseFrequency',
21
+ 'baseline-shift',
22
+ 'baseProfile',
23
+ 'bbox',
24
+ 'begin',
25
+ 'bias',
26
+ 'by',
27
+ 'calcMode',
28
+ 'cap-height',
29
+ 'class',
30
+ 'clip',
31
+ 'clipPathUnits',
32
+ 'clip-path',
33
+ 'clip-rule',
34
+ 'color',
35
+ 'color-interpolation',
36
+ 'color-interpolation-filters',
37
+ 'color-profile',
38
+ 'color-rendering',
39
+ 'contentScriptType',
40
+ 'contentStyleType',
41
+ 'cursor',
42
+ 'cx',
43
+ 'cy',
44
+ 'd',
45
+ 'decelerate',
46
+ 'descent',
47
+ 'diffuseConstant',
48
+ 'direction',
49
+ 'display',
50
+ 'divisor',
51
+ 'dominant-baseline',
52
+ 'dur',
53
+ 'dx',
54
+ 'dy',
55
+ 'edgeMode',
56
+ 'elevation',
57
+ 'enable-background',
58
+ 'end',
59
+ 'exponent',
60
+ 'externalResourcesRequired',
61
+ 'fill',
62
+ 'fill-opacity',
63
+ 'fill-rule',
64
+ 'filter',
65
+ 'filterRes',
66
+ 'filterUnits',
67
+ 'flood-color',
68
+ 'flood-opacity',
69
+ 'font-family',
70
+ 'font-size',
71
+ 'font-size-adjust',
72
+ 'font-stretch',
73
+ 'font-style',
74
+ 'font-variant',
75
+ 'font-weight',
76
+ 'format',
77
+ 'from',
78
+ 'fx',
79
+ 'fy',
80
+ 'g1',
81
+ 'g2',
82
+ 'glyph-name',
83
+ 'glyph-orientation-horizontal',
84
+ 'glyph-orientation-vertical',
85
+ 'glyphRef',
86
+ 'gradientTransform',
87
+ 'gradientUnits',
88
+ 'hanging',
89
+ 'height',
90
+ 'horiz-adv-x',
91
+ 'horiz-origin-x',
92
+ 'id',
93
+ 'ideographic',
94
+ 'image-rendering',
95
+ 'in',
96
+ 'in2',
97
+ 'intercept',
98
+ 'k',
99
+ 'k1',
100
+ 'k2',
101
+ 'k3',
102
+ 'k4',
103
+ 'kernelMatrix',
104
+ 'kernelUnitLength',
105
+ 'kerning',
106
+ 'keyPoints',
107
+ 'keySplines',
108
+ 'keyTimes',
109
+ 'lang',
110
+ 'lengthAdjust',
111
+ 'letter-spacing',
112
+ 'lighting-color',
113
+ 'limitingConeAngle',
114
+ 'local',
115
+ 'marker-end',
116
+ 'marker-mid',
117
+ 'marker-start',
118
+ 'markerHeight',
119
+ 'markerUnits',
120
+ 'markerWidth',
121
+ 'mask',
122
+ 'maskContentUnits',
123
+ 'maskUnits',
124
+ 'mathematical',
125
+ 'max',
126
+ 'media',
127
+ 'method',
128
+ 'min',
129
+ 'mode',
130
+ 'name',
131
+ 'numOctaves',
132
+ 'offset',
133
+ 'opacity',
134
+ 'operator',
135
+ 'order',
136
+ 'orient',
137
+ 'orientation',
138
+ 'origin',
139
+ 'overflow',
140
+ 'overline-position',
141
+ 'overline-thickness',
142
+ 'panose-1',
143
+ 'paint-order',
144
+ 'path',
145
+ 'pathLength',
146
+ 'patternContentUnits',
147
+ 'patternTransform',
148
+ 'patternUnits',
149
+ 'pointer-events',
150
+ 'points',
151
+ 'pointsAtX',
152
+ 'pointsAtY',
153
+ 'pointsAtZ',
154
+ 'preserveAlpha',
155
+ 'preserveAspectRatio',
156
+ 'primitiveUnits',
157
+ 'r',
158
+ 'radius',
159
+ 'refX',
160
+ 'refY',
161
+ 'rendering-intent',
162
+ 'repeatCount',
163
+ 'repeatDur',
164
+ 'requiredExtensions',
165
+ 'requiredFeatures',
166
+ 'restart',
167
+ 'result',
168
+ 'rotate',
169
+ 'rx',
170
+ 'ry',
171
+ 'scale',
172
+ 'seed',
173
+ 'shape-rendering',
174
+ 'slope',
175
+ 'spacing',
176
+ 'specularConstant',
177
+ 'specularExponent',
178
+ 'speed',
179
+ 'spreadMethod',
180
+ 'startOffset',
181
+ 'stdDeviation',
182
+ 'stemh',
183
+ 'stemv',
184
+ 'stitchTiles',
185
+ 'stop-color',
186
+ 'stop-opacity',
187
+ 'strikethrough-position',
188
+ 'strikethrough-thickness',
189
+ 'string',
190
+ 'stroke',
191
+ 'stroke-dasharray',
192
+ 'stroke-dashoffset',
193
+ 'stroke-linecap',
194
+ 'stroke-linejoin',
195
+ 'stroke-miterlimit',
196
+ 'stroke-opacity',
197
+ 'stroke-width',
198
+ 'style',
199
+ 'surfaceScale',
200
+ 'systemLanguage',
201
+ 'tableValues',
202
+ 'target',
203
+ 'targetX',
204
+ 'targetY',
205
+ 'text-anchor',
206
+ 'text-decoration',
207
+ 'text-rendering',
208
+ 'textLength',
209
+ 'to',
210
+ 'transform',
211
+ 'type',
212
+ 'u1',
213
+ 'u2',
214
+ 'underline-position',
215
+ 'underline-thickness',
216
+ 'unicode',
217
+ 'unicode-bidi',
218
+ 'unicode-range',
219
+ 'units-per-em',
220
+ 'v-alphabetic',
221
+ 'v-hanging',
222
+ 'v-ideographic',
223
+ 'v-mathematical',
224
+ 'values',
225
+ 'version',
226
+ 'vert-adv-y',
227
+ 'vert-origin-x',
228
+ 'vert-origin-y',
229
+ 'viewBox',
230
+ 'viewTarget',
231
+ 'visibility',
232
+ 'width',
233
+ 'widths',
234
+ 'word-spacing',
235
+ 'writing-mode',
236
+ 'x',
237
+ 'x-height',
238
+ 'x1',
239
+ 'x2',
240
+ 'xChannelSelector',
241
+ 'y',
242
+ 'y1',
243
+ 'y2',
244
+ 'yChannelSelector',
245
+ 'z',
246
+ 'zoomAndPan'
247
+ ];
248
+ var defaultTags = [
249
+ 'animate',
250
+ 'animateColor',
251
+ 'animateMotion',
252
+ 'animateTransform',
253
+ 'mpath',
254
+ 'set',
255
+ 'circle',
256
+ 'ellipse',
257
+ 'line',
258
+ 'polygon',
259
+ 'polyline',
260
+ 'rect',
261
+ 'defs',
262
+ 'glyph',
263
+ 'g',
264
+ 'marker',
265
+ 'mask',
266
+ 'missing-glyph',
267
+ 'pattern',
268
+ 'svg',
269
+ 'switch',
270
+ 'symbol',
271
+ 'font',
272
+ 'font-face',
273
+ 'font-face-format',
274
+ 'font-face-name',
275
+ 'font-face-src',
276
+ 'font-face-uri',
277
+ 'hkern',
278
+ 'vkern',
279
+ 'linearGradient',
280
+ 'radialGradient',
281
+ 'stop',
282
+ 'circle',
283
+ 'ellipse',
284
+ 'image',
285
+ 'line',
286
+ 'path',
287
+ 'polygon',
288
+ 'polyline',
289
+ 'rect',
290
+ 'text',
291
+ 'use',
292
+ 'feDistantLight',
293
+ 'fePointLight',
294
+ 'feSpotLight',
295
+ 'circle',
296
+ 'ellipse',
297
+ 'line',
298
+ 'path',
299
+ 'polygon',
300
+ 'polyline',
301
+ 'rect',
302
+ 'defs',
303
+ 'g',
304
+ 'svg',
305
+ 'symbol',
306
+ 'use',
307
+ 'altGlyph',
308
+ 'altGlyphDef',
309
+ 'altGlyphItem',
310
+ 'glyph',
311
+ 'glyphRef',
312
+ 'textPath',
313
+ 'text',
314
+ 'tref',
315
+ 'tspan',
316
+ 'altGlyph',
317
+ 'textPath',
318
+ 'tref',
319
+ 'tspan',
320
+ 'clipPath',
321
+ 'color-profile',
322
+ 'cursor',
323
+ 'filter',
324
+ 'foreignObject',
325
+ 'script',
326
+ 'style',
327
+ 'view'
328
+ ];
329
+ export default {
330
+ attributes: {
331
+ '*': __spreadArray(__spreadArray([], defaultAttributes), ['ui-actions', 'ui-tooltip']),
332
+ img: ['src', 'srcset', 'alt', 'title', 'loading'],
333
+ link: ['href', 'rel'],
334
+ iframe: ['src'],
335
+ a: ['href']
336
+ },
337
+ tags: __spreadArray(__spreadArray([], defaultTags), ['a', 'link', 'input', 'button', 'iframe', 'img'])
338
+ };
@@ -15,6 +15,7 @@ import mdmModule, { ui } from '@reltio/mdm-module';
15
15
  import { CustomAction, CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
16
16
  import { omit } from 'ramda';
17
17
  import { useWorkflowCheckPermission } from '../../components/workflow';
18
+ import { useHtmlSanitizer } from '../useHtmlSanitizer';
18
19
  import { InterceptHandlersContext, SandboxAPIContext, SnackbarContext } from '../../contexts';
19
20
  import { processRequest } from './API';
20
21
  import { getWorkerURL, resetHtml, isNewUI, setUpResponseInterceptor, setUpRequestInterceptor, setUpQooxdooRequestInterceptor, setUpQooxdooResponseInterceptor } from './helpers';
@@ -32,6 +33,7 @@ export var useAPI = function (config) {
32
33
  var requestListeners = useRef({});
33
34
  var responseListeners = useRef({});
34
35
  var dispatch = useDispatch();
36
+ var sanitizeHtml = useHtmlSanitizer();
35
37
  var uiPath = useSelector(mdmModule.selectors.getUIPath);
36
38
  var tenant = useSelector(mdmModule.selectors.getTenant);
37
39
  var workerUrl = getWorkerURL(uiPath, tenant);
@@ -60,16 +62,17 @@ export var useAPI = function (config) {
60
62
  if (task) {
61
63
  switch (task.action) {
62
64
  case CustomAction.SET_HTML: {
65
+ var sanitizedHtml = sanitizeHtml(task.params.html);
63
66
  if (task.params.id) {
64
67
  var elem = document.getElementById(task.params.id);
65
- elem.innerHTML = task.params.html;
68
+ elem.innerHTML = sanitizedHtml;
66
69
  }
67
- else if (innerText !== task.params.html) {
68
- innerText = task.params.html;
70
+ else if (innerText !== sanitizedHtml) {
71
+ innerText = sanitizedHtml;
69
72
  resetHtml({
70
73
  worker: worker,
71
74
  setTooltip: setTooltip,
72
- html: task.params.html,
75
+ html: sanitizedHtml,
73
76
  innerText: innerText,
74
77
  setListenersToReset: setListenersToReset,
75
78
  setHtml: setHtml
@@ -78,11 +81,12 @@ export var useAPI = function (config) {
78
81
  break;
79
82
  }
80
83
  case CustomAction.SHOW_POPUP: {
81
- popupText = task.params;
84
+ var sanitizedPopup = sanitizeHtml(task.params);
85
+ popupText = sanitizedPopup;
82
86
  resetHtml({
83
87
  worker: worker,
84
88
  setTooltip: setTooltip,
85
- html: task.params,
89
+ html: sanitizedPopup,
86
90
  innerText: popupText,
87
91
  setListenersToReset: setPopupListenersToReset,
88
92
  setHtml: setPopup
@@ -0,0 +1 @@
1
+ export declare const useHtmlSanitizer: () => (html: string) => string;
@@ -0,0 +1,23 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import sanitizeHtml from 'sanitize-html';
13
+ import sanitizeOptions from './helpers/sanitizerOptions';
14
+ export var useHtmlSanitizer = function () {
15
+ var _a = sanitizeHtml.defaults, allowedAttributes = _a.allowedAttributes, allowedTags = _a.allowedTags;
16
+ var attributes = sanitizeOptions.attributes, tags = sanitizeOptions.tags;
17
+ var options = {
18
+ allowedTags: allowedTags.concat(tags),
19
+ allowedAttributes: __assign(__assign({}, allowedAttributes), attributes),
20
+ allowVulnerableTags: true
21
+ };
22
+ return function (html) { return sanitizeHtml(html, options); };
23
+ };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1252",
3
+ "version": "1.4.1254",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-module": "^1.4.1252",
11
- "@reltio/mdm-sdk": "^1.4.1252",
10
+ "@reltio/mdm-module": "^1.4.1254",
11
+ "@reltio/mdm-sdk": "^1.4.1254",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",
@@ -36,6 +36,7 @@
36
36
  "react-virtualized": "^9.21.2",
37
37
  "react-window": "^1.8.5",
38
38
  "recharts": "^1.8.5",
39
+ "sanitize-html": "^2.7.1",
39
40
  "ui-i18n": "bitbucket:reltio-ondemand/ui-i18n#v1.4.0"
40
41
  },
41
42
  "peerDependencies": {