@jupyterlab/apputils 4.6.0-alpha.0 → 4.6.0-alpha.2
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/lib/clipboard.d.ts +43 -0
- package/lib/clipboard.js +156 -0
- package/lib/clipboard.js.map +1 -1
- package/lib/dialog.js +1 -0
- package/lib/dialog.js.map +1 -1
- package/lib/kernelstatuses.js +1 -1
- package/lib/kernelstatuses.js.map +1 -1
- package/lib/mainareawidget.js +2 -2
- package/lib/mainareawidget.js.map +1 -1
- package/lib/runningSessions.js +1 -1
- package/lib/runningSessions.js.map +1 -1
- package/lib/sanitizer.d.ts +8 -1
- package/lib/sanitizer.js +702 -508
- package/lib/sanitizer.js.map +1 -1
- package/package.json +11 -11
- package/src/clipboard.ts +200 -0
- package/src/dialog.tsx +1 -0
- package/src/kernelstatuses.tsx +2 -0
- package/src/mainareawidget.ts +2 -2
- package/src/runningSessions.tsx +1 -0
- package/src/sanitizer.ts +714 -508
- package/style/dialog.css +8 -2
package/lib/sanitizer.js
CHANGED
|
@@ -23,6 +23,8 @@ CssProp.N = {
|
|
|
23
23
|
integer: `[+-]?[0-9]+`,
|
|
24
24
|
integer_pos: `[+]?[0-9]+`,
|
|
25
25
|
integer_zero_ff: `([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])`,
|
|
26
|
+
integer_non_zero: `[+-]?([1-9][0-9]*)`,
|
|
27
|
+
integer_pos_non_zero: `[+]?([1-9][0-9]*)`,
|
|
26
28
|
number: `[+-]?([0-9]*[.])?[0-9]+(e-?[0-9]*)?`,
|
|
27
29
|
number_pos: `[+]?([0-9]*[.])?[0-9]+(e-?[0-9]*)?`,
|
|
28
30
|
number_zero_hundred: `[+]?(([0-9]|[1-9][0-9])([.][0-9]+)?|100)`,
|
|
@@ -31,7 +33,7 @@ CssProp.N = {
|
|
|
31
33
|
/*
|
|
32
34
|
* Base expressions of common CSS syntax elements
|
|
33
35
|
*/
|
|
34
|
-
CssProp.
|
|
36
|
+
CssProp._B = {
|
|
35
37
|
angle: `(${CssProp.N.number}(deg|rad|grad|turn)|0)`,
|
|
36
38
|
frequency: `${CssProp.N.number}(Hz|kHz)`,
|
|
37
39
|
ident: String.raw `-?([_a-z]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*`,
|
|
@@ -46,6 +48,46 @@ CssProp.B = {
|
|
|
46
48
|
url: `url\\(.*?\\)`,
|
|
47
49
|
z_index: `[+-]?[0-9]{1,7}`
|
|
48
50
|
};
|
|
51
|
+
/*
|
|
52
|
+
* Extended base expressions of common CSS syntax elements
|
|
53
|
+
*/
|
|
54
|
+
CssProp._B1 = {
|
|
55
|
+
flex: `(${CssProp.N.number}|${CssProp._B.len_or_perc}|none|auto)\\s*((${CssProp.N.number}|${CssProp._B.len_or_perc}|auto)\\s*){0,2}`,
|
|
56
|
+
fixed_breadth: `${CssProp._B.len_or_perc}`,
|
|
57
|
+
grid_line: `auto|${CssProp._B.ident}|(${CssProp.N.integer_non_zero}(\\s+${CssProp._B.ident})?)|(span\\s+(${CssProp.N.integer_pos_non_zero}|${CssProp._B.ident}))`,
|
|
58
|
+
line_names: String.raw `\[\s*${CssProp._B.ident}(\s+${CssProp._B.ident})*\s*\]`
|
|
59
|
+
};
|
|
60
|
+
CssProp._B2 = {
|
|
61
|
+
inflexible_breadth: `${CssProp._B.len_or_perc}|auto|min-content|max-content`,
|
|
62
|
+
track_breadth: `${CssProp._B.len_or_perc}|${CssProp._B1.flex}|auto|min-content|max-content`
|
|
63
|
+
};
|
|
64
|
+
CssProp._B3 = {
|
|
65
|
+
fixed_size: `${CssProp._B1.fixed_breadth}|minmax\\(\\s*${CssProp._B2.inflexible_breadth}\\s*,\\s*${CssProp._B1.fixed_breadth}\\s*\\)|minmax\\(\\s*${CssProp._B1.fixed_breadth}\\s*,\\s*${CssProp._B2.track_breadth}\\s*\\)`,
|
|
66
|
+
track_size: `${CssProp._B2.track_breadth}|minmax\\(\\s*${CssProp._B2.inflexible_breadth}\\s*,\\s*${CssProp._B2.track_breadth}\\s*\\)|fit-content\\(\\s*(${CssProp._B.len_or_perc}\\s*)*\\)`
|
|
67
|
+
};
|
|
68
|
+
CssProp._B4 = {
|
|
69
|
+
name_repeat: `repeat\\(\\s*(${CssProp.N.integer_pos_non_zero}|auto-fill)\\s*,\\s*(${CssProp._B1.line_names})+\\s*\\)`,
|
|
70
|
+
auto_repeat: `repeat\\(\\s*(auto-fill|auto-fit)\\s*,\\s*((${CssProp._B1.line_names}\\s+)?${CssProp._B3.fixed_size}\\s*)+(${CssProp._B1.line_names})?\\s*\\)`,
|
|
71
|
+
fixed_repeat: `repeat\\(\\s*(${CssProp.N.integer_pos_non_zero})\\s*,\\s*((${CssProp._B1.line_names}\\s+)?${CssProp._B3.fixed_size}\\s*)+(${CssProp._B1.line_names})?\\s*\\)`
|
|
72
|
+
};
|
|
73
|
+
CssProp._B5 = {
|
|
74
|
+
auto_track_list: `(${CssProp._B1.line_names}\\s*)?(${CssProp._B3.fixed_size}|${CssProp._B4.fixed_repeat})*(${CssProp._B1.line_names}\\s*)?${CssProp._B4.auto_repeat}(${CssProp._B1.line_names}\\s*)?(${CssProp._B3.fixed_size}|${CssProp._B4.fixed_repeat})*(${CssProp._B1.line_names}\\s*)?`,
|
|
75
|
+
explicit_track_list: `(${CssProp._B1.line_names}\\s*)?(${CssProp._B3.track_size})+(${CssProp._B1.line_names}\\s*)?`,
|
|
76
|
+
track_list: `(${CssProp._B1.line_names}\\s*)?(${CssProp._B3.track_size}|${CssProp._B4.name_repeat})+(${CssProp._B1.line_names}\\s*)?`
|
|
77
|
+
};
|
|
78
|
+
CssProp._B6 = {
|
|
79
|
+
grid_template_rows: `none|${CssProp._B5.track_list}|${CssProp._B5.auto_track_list}|subgrid\\s*(${CssProp._B1.line_names})?`,
|
|
80
|
+
grid_template_columns: `none|${CssProp._B5.track_list}|${CssProp._B5.auto_track_list}|subgrid\\s*(${CssProp._B1.line_names})?`
|
|
81
|
+
};
|
|
82
|
+
CssProp.B = {
|
|
83
|
+
...CssProp._B,
|
|
84
|
+
...CssProp._B1,
|
|
85
|
+
...CssProp._B2,
|
|
86
|
+
...CssProp._B3,
|
|
87
|
+
...CssProp._B4,
|
|
88
|
+
...CssProp._B5,
|
|
89
|
+
...CssProp._B6
|
|
90
|
+
};
|
|
49
91
|
/*
|
|
50
92
|
* Atomic (i.e. not dependent on other regular expressions) sub RegEx segments
|
|
51
93
|
*/
|
|
@@ -130,29 +172,44 @@ CssProp.C = {
|
|
|
130
172
|
* Property value regular expressions not dependent on other sub expressions
|
|
131
173
|
*/
|
|
132
174
|
CssProp.AP = {
|
|
175
|
+
baseline_position: `baseline|first baseline|last baseline`,
|
|
133
176
|
border_collapse: `collapse|separate`,
|
|
134
177
|
box: `normal|none|contents`,
|
|
135
178
|
box_sizing: `content-box|padding-box|border-box`,
|
|
136
179
|
caption_side: `top|bottom`,
|
|
137
180
|
clear: `none|left|right|both`,
|
|
181
|
+
content_position: `start|end|center|flex-start|flex-end`,
|
|
182
|
+
content_distribution: `stretch|space-between|space-around|space-evenly`,
|
|
138
183
|
direction: `ltr|rtl`,
|
|
139
184
|
empty_cells: `show|hide`,
|
|
185
|
+
flex_direction: `row|row-reverse|column|column-reverse`,
|
|
186
|
+
flex_wrap: `nowrap|wrap|wrap-reverse`,
|
|
140
187
|
float: `left|right|none`,
|
|
141
188
|
font_stretch: `normal|wider|narrower|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded`,
|
|
142
189
|
font_style: `normal|italic|oblique`,
|
|
143
190
|
font_variant: `normal|small-caps`,
|
|
144
191
|
font_weight: `normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900`,
|
|
145
192
|
list_style_position: `inside|outside`,
|
|
193
|
+
gap: `normal`,
|
|
194
|
+
grid_auto_flow: `row|column|dense|row dense|column dense`,
|
|
195
|
+
justify_content: `start|end|center|stretch|space-between|space-around|space-evenly`,
|
|
196
|
+
justify_items: `start|end|center|stretch`,
|
|
197
|
+
justify_self: `auto|start|end|center|stretch`,
|
|
146
198
|
list_style_type: `disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-greek|lower-latin|upper-latin|armenian|georgian|lower-alpha|upper-alpha|none`,
|
|
147
199
|
overflow: `visible|hidden|scroll|auto`,
|
|
200
|
+
overflow_position: `unsafe|safe`,
|
|
148
201
|
overflow_wrap: `normal|break-word`,
|
|
149
202
|
overflow_x: `visible|hidden|scroll|auto|no-display|no-content`,
|
|
150
203
|
page_break_after: `auto|always|avoid|left|right`,
|
|
151
204
|
page_break_before: `auto|always|avoid|left|right`,
|
|
152
205
|
page_break_inside: `avoid|auto`,
|
|
206
|
+
place_content: `(center|start|end|space-between|space-around|space-evenly|stretch){1,2}`,
|
|
207
|
+
place_items: `(center|start|end|baseline|stretch){1,2}`,
|
|
208
|
+
place_self: `(center|start|end|baseline|stretch){1,2}`,
|
|
153
209
|
position: `static|relative|absolute`,
|
|
154
210
|
resize: `none|both|horizontal|vertical`,
|
|
155
211
|
speak: `normal|none|spell-out`,
|
|
212
|
+
self_position: `center|start|end|self-start|self-end|flex-start|flex-end`,
|
|
156
213
|
speak_header: `once|always`,
|
|
157
214
|
speak_numeral: `digits|continuous`,
|
|
158
215
|
speak_punctuation: `code|none`,
|
|
@@ -170,6 +227,9 @@ CssProp.AP = {
|
|
|
170
227
|
* Compound propertiy value regular expressions (i.e. dependent on other sub expressions)
|
|
171
228
|
*/
|
|
172
229
|
CssProp._CP = {
|
|
230
|
+
align_content: `normal|${CssProp.AP.baseline_position}|${CssProp.AP.content_distribution}|${CssProp.AP.overflow_position}|${CssProp.AP.content_position}`,
|
|
231
|
+
align_items: `normal|stretch|${CssProp.AP.baseline_position}|(${CssProp.AP.overflow_position})?\\s*${CssProp.AP.self_position}|anchor-center`,
|
|
232
|
+
align_self: `auto|normal|stretch|${CssProp.AP.baseline_position}|(${CssProp.AP.overflow_position})?\\s*${CssProp.AP.self_position}|anchor-center`,
|
|
173
233
|
background_attachment: `${CssProp.A.attachment}(,\\s*${CssProp.A.attachment})*`,
|
|
174
234
|
background_color: CssProp.C.color,
|
|
175
235
|
background_origin: `${CssProp.A.box}(,\\s*${CssProp.A.box})*`,
|
|
@@ -264,7 +324,32 @@ CssProp._CP = {
|
|
|
264
324
|
border_left: `((${CssProp.C.border_width}|${CssProp.A.border_style}|${CssProp.C.color})\\s*){1,3}`,
|
|
265
325
|
quotes: `(${CssProp.B.string}\\s*${CssProp.B.string})+|none`,
|
|
266
326
|
border_top_right_radius: `(${CssProp.B.length}|${CssProp.B.percentage})(\\s*(${CssProp.B.length}|${CssProp.B.percentage}))?`,
|
|
267
|
-
min_width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|auto
|
|
327
|
+
min_width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|auto`,
|
|
328
|
+
// Add flexbox and grid properties
|
|
329
|
+
flex_basis: `${CssProp.B.len_or_perc}|auto|content|max-content|min-content|fit-content\\(\\s*(${CssProp.B.len_or_perc}\\s*)*\\)`, // simplified no <calc-size()> and <anchor-size()>
|
|
330
|
+
flex_grow: CssProp.N.number_pos,
|
|
331
|
+
flex_shrink: CssProp.N.number_pos,
|
|
332
|
+
grid: `(${CssProp.B.string}|none|subgrid)\\s*(\\/\\s*(${CssProp.B.string}|none|subgrid))?`,
|
|
333
|
+
grid_area: `${CssProp.B.ident}|auto|(${CssProp.N.integer}\\s*\\/\\s*${CssProp.N.integer}\\s*\\/\\s*${CssProp.N.integer}\\s*\\/\\s*${CssProp.N.integer})`,
|
|
334
|
+
grid_auto_columns: `(${CssProp.B.track_size})+`,
|
|
335
|
+
grid_auto_rows: `(${CssProp.B.track_size})+`,
|
|
336
|
+
grid_column: `${CssProp.B.grid_line}(\\s*\\/\\s*${CssProp.B.grid_line})?`,
|
|
337
|
+
grid_column_start: `${CssProp.B.grid_line}`,
|
|
338
|
+
grid_column_end: `${CssProp.B.grid_line}`,
|
|
339
|
+
grid_column_gap: `${CssProp.B.len_or_perc}|normal`,
|
|
340
|
+
grid_gap: `(${CssProp.B.len_or_perc}|normal)(\\s*(${CssProp.B.len_or_perc}|normal))?`,
|
|
341
|
+
grid_row: `${CssProp.B.grid_line}(\\s*\\/\\s*${CssProp.B.grid_line})?`,
|
|
342
|
+
grid_row_start: `${CssProp.B.grid_line}`,
|
|
343
|
+
grid_row_end: `${CssProp.B.grid_line}`,
|
|
344
|
+
grid_row_gap: `${CssProp.B.len_or_perc}|normal`,
|
|
345
|
+
grid_template: `none|(${CssProp.B.grid_template_rows}\\s*\\/\\s*${CssProp.B.grid_template_columns})|(${CssProp.B.line_names}\\s*)?(${CssProp.B.string}\\s*${CssProp.B.track_size}\\s*(${CssProp.B.line_names}\\s*)?)+\\s*(\\/\\s*${CssProp.B.explicit_track_list})?`,
|
|
346
|
+
grid_template_areas: `none|(${CssProp.B.string})+`,
|
|
347
|
+
grid_template_columns: `${CssProp.B.grid_template_columns}`,
|
|
348
|
+
grid_template_rows: `${CssProp.B.grid_template_rows}`,
|
|
349
|
+
row_gap: `${CssProp.B.len_or_perc}|normal`,
|
|
350
|
+
column_gap: `${CssProp.B.len_or_perc}|normal`,
|
|
351
|
+
gap: `(${CssProp.B.len_or_perc}|normal)(\\s*(${CssProp.B.len_or_perc}|normal))?`,
|
|
352
|
+
order: CssProp.N.integer
|
|
268
353
|
};
|
|
269
354
|
CssProp._CP1 = {
|
|
270
355
|
font: `(((((${CssProp.AP.font_style}|${CssProp.AP.font_variant}|${CssProp.AP.font_weight})\\s*){1,3})?\\s*(${CssProp._CP.font_size})\\s*(\\/\\s*(${CssProp._CP.line_height}))?\\s+(${CssProp._CP.font_family}))|caption|icon|menu|message-box|small-caption|status-bar)`
|
|
@@ -401,6 +486,45 @@ CssProp.FONT = CssProp.reg(CssProp.CP.font);
|
|
|
401
486
|
CssProp.QUOTES = CssProp.reg(CssProp.CP.quotes);
|
|
402
487
|
CssProp.BORDER_TOP_RIGHT_RADIUS = CssProp.reg(CssProp.CP.border_top_right_radius);
|
|
403
488
|
CssProp.MIN_WIDTH = CssProp.reg(CssProp.CP.min_width);
|
|
489
|
+
// Flexbox properties
|
|
490
|
+
CssProp.ALIGN_CONTENT = CssProp.reg(CssProp.CP.align_content);
|
|
491
|
+
CssProp.ALIGN_ITEMS = CssProp.reg(CssProp.CP.align_items);
|
|
492
|
+
CssProp.ALIGN_SELF = CssProp.reg(CssProp.CP.align_self);
|
|
493
|
+
CssProp.FLEX = CssProp.reg(CssProp.B.flex);
|
|
494
|
+
CssProp.FLEX_BASIS = CssProp.reg(CssProp.CP.flex_basis);
|
|
495
|
+
CssProp.FLEX_DIRECTION = CssProp.reg(CssProp.AP.flex_direction);
|
|
496
|
+
CssProp.FLEX_GROW = CssProp.reg(CssProp.CP.flex_grow);
|
|
497
|
+
CssProp.FLEX_SHRINK = CssProp.reg(CssProp.CP.flex_shrink);
|
|
498
|
+
CssProp.FLEX_WRAP = CssProp.reg(CssProp.AP.flex_wrap);
|
|
499
|
+
CssProp.JUSTIFY_CONTENT = CssProp.reg(CssProp.AP.justify_content);
|
|
500
|
+
CssProp.JUSTIFY_ITEMS = CssProp.reg(CssProp.AP.justify_items);
|
|
501
|
+
CssProp.JUSTIFY_SELF = CssProp.reg(CssProp.AP.justify_self);
|
|
502
|
+
CssProp.ORDER = CssProp.reg(CssProp.CP.order);
|
|
503
|
+
// Grid properties
|
|
504
|
+
CssProp.GRID = CssProp.reg(CssProp.CP.grid);
|
|
505
|
+
CssProp.GRID_AREA = CssProp.reg(CssProp.CP.grid_area);
|
|
506
|
+
CssProp.GRID_AUTO_COLUMNS = CssProp.reg(CssProp.CP.grid_auto_columns);
|
|
507
|
+
CssProp.GRID_AUTO_FLOW = CssProp.reg(CssProp.AP.grid_auto_flow);
|
|
508
|
+
CssProp.GRID_AUTO_ROWS = CssProp.reg(CssProp.CP.grid_auto_rows);
|
|
509
|
+
CssProp.GRID_COLUMN = CssProp.reg(CssProp.CP.grid_column);
|
|
510
|
+
CssProp.GRID_COLUMN_END = CssProp.reg(CssProp.CP.grid_column_end);
|
|
511
|
+
CssProp.GRID_COLUMN_GAP = CssProp.reg(CssProp.CP.grid_column_gap);
|
|
512
|
+
CssProp.GRID_COLUMN_START = CssProp.reg(CssProp.CP.grid_column_start);
|
|
513
|
+
CssProp.GRID_GAP = CssProp.reg(CssProp.CP.grid_gap);
|
|
514
|
+
CssProp.GRID_ROW = CssProp.reg(CssProp.CP.grid_row);
|
|
515
|
+
CssProp.GRID_ROW_END = CssProp.reg(CssProp.CP.grid_row_end);
|
|
516
|
+
CssProp.GRID_ROW_GAP = CssProp.reg(CssProp.CP.grid_row_gap);
|
|
517
|
+
CssProp.GRID_ROW_START = CssProp.reg(CssProp.CP.grid_row_start);
|
|
518
|
+
CssProp.GRID_TEMPLATE = CssProp.reg(CssProp.CP.grid_template);
|
|
519
|
+
CssProp.GRID_TEMPLATE_AREAS = CssProp.reg(CssProp.CP.grid_template_areas);
|
|
520
|
+
CssProp.GRID_TEMPLATE_COLUMNS = CssProp.reg(CssProp.CP.grid_template_columns);
|
|
521
|
+
CssProp.GRID_TEMPLATE_ROWS = CssProp.reg(CssProp.CP.grid_template_rows);
|
|
522
|
+
CssProp.GAP = CssProp.reg(CssProp.CP.gap);
|
|
523
|
+
CssProp.ROW_GAP = CssProp.reg(CssProp.CP.row_gap);
|
|
524
|
+
CssProp.COLUMN_GAP = CssProp.reg(CssProp.CP.column_gap);
|
|
525
|
+
CssProp.PLACE_CONTENT = CssProp.reg(CssProp.AP.place_content);
|
|
526
|
+
CssProp.PLACE_ITEMS = CssProp.reg(CssProp.AP.place_items);
|
|
527
|
+
CssProp.PLACE_SELF = CssProp.reg(CssProp.AP.place_self);
|
|
404
528
|
/**
|
|
405
529
|
* A class to sanitize HTML strings.
|
|
406
530
|
*/
|
|
@@ -408,514 +532,575 @@ export class Sanitizer {
|
|
|
408
532
|
constructor() {
|
|
409
533
|
this._autolink = true;
|
|
410
534
|
this._allowNamedProperties = false;
|
|
411
|
-
this._generateOptions = () =>
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
'article',
|
|
420
|
-
'aside',
|
|
421
|
-
'audio',
|
|
422
|
-
'b',
|
|
423
|
-
'bdi',
|
|
424
|
-
'bdo',
|
|
425
|
-
'big',
|
|
426
|
-
'blockquote',
|
|
427
|
-
'br',
|
|
428
|
-
'button',
|
|
429
|
-
'canvas',
|
|
430
|
-
'caption',
|
|
431
|
-
'center',
|
|
432
|
-
'cite',
|
|
433
|
-
'code',
|
|
434
|
-
'col',
|
|
435
|
-
'colgroup',
|
|
436
|
-
'colspan',
|
|
437
|
-
'command',
|
|
438
|
-
'data',
|
|
439
|
-
'datalist',
|
|
440
|
-
'dd',
|
|
441
|
-
'del',
|
|
442
|
-
'details',
|
|
443
|
-
'dfn',
|
|
444
|
-
'dir',
|
|
445
|
-
'div',
|
|
446
|
-
'dl',
|
|
447
|
-
'dt',
|
|
448
|
-
'em',
|
|
449
|
-
'fieldset',
|
|
450
|
-
'figcaption',
|
|
451
|
-
'figure',
|
|
452
|
-
'font',
|
|
453
|
-
'footer',
|
|
454
|
-
'form',
|
|
455
|
-
'h1',
|
|
456
|
-
'h2',
|
|
457
|
-
'h3',
|
|
458
|
-
'h4',
|
|
459
|
-
'h5',
|
|
460
|
-
'h6',
|
|
461
|
-
'header',
|
|
462
|
-
'hgroup',
|
|
463
|
-
'hr',
|
|
464
|
-
'i',
|
|
465
|
-
// 'iframe' is allowed by Google Caja, but disallowed by default by sanitize-html
|
|
466
|
-
// , 'iframe'
|
|
467
|
-
'img',
|
|
468
|
-
'input',
|
|
469
|
-
'ins',
|
|
470
|
-
'kbd',
|
|
471
|
-
'label',
|
|
472
|
-
'legend',
|
|
473
|
-
'li',
|
|
474
|
-
'map',
|
|
475
|
-
'mark',
|
|
476
|
-
'menu',
|
|
477
|
-
'meter',
|
|
478
|
-
'nav',
|
|
479
|
-
'nobr',
|
|
480
|
-
'ol',
|
|
481
|
-
'optgroup',
|
|
482
|
-
'option',
|
|
483
|
-
'output',
|
|
484
|
-
'p',
|
|
485
|
-
'pre',
|
|
486
|
-
'progress',
|
|
487
|
-
'q',
|
|
488
|
-
'rowspan',
|
|
489
|
-
's',
|
|
490
|
-
'samp',
|
|
491
|
-
'section',
|
|
492
|
-
'select',
|
|
493
|
-
'small',
|
|
494
|
-
'source',
|
|
495
|
-
'span',
|
|
496
|
-
'strike',
|
|
497
|
-
'strong',
|
|
498
|
-
'sub',
|
|
499
|
-
'summary',
|
|
500
|
-
'sup',
|
|
501
|
-
'table',
|
|
502
|
-
'tbody',
|
|
503
|
-
'td',
|
|
504
|
-
'textarea',
|
|
505
|
-
'tfoot',
|
|
506
|
-
'th',
|
|
507
|
-
'thead',
|
|
508
|
-
'time',
|
|
509
|
-
'tr',
|
|
510
|
-
'track',
|
|
511
|
-
'tt',
|
|
512
|
-
'u',
|
|
513
|
-
'ul',
|
|
514
|
-
'var',
|
|
515
|
-
'video',
|
|
516
|
-
'wbr'
|
|
517
|
-
],
|
|
518
|
-
// Attributes that HTML tags are allowed to have, extracted from Google Caja.
|
|
519
|
-
// See https://github.com/jupyterlab/jupyterlab/issues/1812#issuecomment-285848435
|
|
520
|
-
allowedAttributes: {
|
|
521
|
-
'*': [
|
|
522
|
-
'class',
|
|
523
|
-
'dir',
|
|
524
|
-
'draggable',
|
|
525
|
-
'hidden',
|
|
526
|
-
...(this._allowNamedProperties ? ['id'] : []),
|
|
527
|
-
'inert',
|
|
528
|
-
'itemprop',
|
|
529
|
-
'itemref',
|
|
530
|
-
'itemscope',
|
|
531
|
-
'lang',
|
|
532
|
-
'spellcheck',
|
|
533
|
-
'style',
|
|
534
|
-
'title',
|
|
535
|
-
'translate'
|
|
536
|
-
],
|
|
537
|
-
// 'rel' and 'target' were *not* allowed by Google Caja
|
|
538
|
-
a: [
|
|
539
|
-
'accesskey',
|
|
540
|
-
'coords',
|
|
541
|
-
'href',
|
|
542
|
-
'hreflang',
|
|
543
|
-
...(this._allowNamedProperties ? ['name'] : []),
|
|
544
|
-
'rel',
|
|
545
|
-
'shape',
|
|
546
|
-
'tabindex',
|
|
547
|
-
'target',
|
|
548
|
-
'type'
|
|
549
|
-
],
|
|
550
|
-
area: [
|
|
551
|
-
'accesskey',
|
|
552
|
-
'alt',
|
|
553
|
-
'coords',
|
|
554
|
-
'href',
|
|
555
|
-
'nohref',
|
|
556
|
-
'shape',
|
|
557
|
-
'tabindex'
|
|
558
|
-
],
|
|
559
|
-
// 'autoplay' was *not* allowed by Google Caja
|
|
560
|
-
audio: [
|
|
561
|
-
'autoplay',
|
|
562
|
-
'controls',
|
|
563
|
-
'loop',
|
|
564
|
-
'mediagroup',
|
|
565
|
-
'muted',
|
|
566
|
-
'preload',
|
|
567
|
-
'src'
|
|
568
|
-
],
|
|
569
|
-
bdo: ['dir'],
|
|
570
|
-
blockquote: ['cite'],
|
|
571
|
-
br: ['clear'],
|
|
572
|
-
button: [
|
|
573
|
-
'accesskey',
|
|
574
|
-
'data-commandlinker-args',
|
|
575
|
-
'data-commandlinker-command',
|
|
576
|
-
'disabled',
|
|
577
|
-
...(this._allowNamedProperties ? ['name'] : []),
|
|
578
|
-
'tabindex',
|
|
579
|
-
'type',
|
|
580
|
-
'value'
|
|
581
|
-
],
|
|
582
|
-
canvas: ['height', 'width'],
|
|
583
|
-
caption: ['align'],
|
|
584
|
-
col: ['align', 'char', 'charoff', 'span', 'valign', 'width'],
|
|
585
|
-
colgroup: ['align', 'char', 'charoff', 'span', 'valign', 'width'],
|
|
586
|
-
command: [
|
|
587
|
-
'checked',
|
|
588
|
-
'command',
|
|
589
|
-
'disabled',
|
|
590
|
-
'icon',
|
|
591
|
-
'label',
|
|
592
|
-
'radiogroup',
|
|
593
|
-
'type'
|
|
594
|
-
],
|
|
595
|
-
data: ['value'],
|
|
596
|
-
del: ['cite', 'datetime'],
|
|
597
|
-
details: ['open'],
|
|
598
|
-
dir: ['compact'],
|
|
599
|
-
div: ['align'],
|
|
600
|
-
dl: ['compact'],
|
|
601
|
-
fieldset: ['disabled'],
|
|
602
|
-
font: ['color', 'face', 'size'],
|
|
603
|
-
form: [
|
|
604
|
-
'accept',
|
|
605
|
-
'autocomplete',
|
|
606
|
-
'enctype',
|
|
607
|
-
'method',
|
|
608
|
-
...(this._allowNamedProperties ? ['name'] : []),
|
|
609
|
-
'novalidate'
|
|
610
|
-
],
|
|
611
|
-
h1: ['align'],
|
|
612
|
-
h2: ['align'],
|
|
613
|
-
h3: ['align'],
|
|
614
|
-
h4: ['align'],
|
|
615
|
-
h5: ['align'],
|
|
616
|
-
h6: ['align'],
|
|
617
|
-
hr: ['align', 'noshade', 'size', 'width'],
|
|
618
|
-
iframe: [
|
|
619
|
-
'align',
|
|
620
|
-
'frameborder',
|
|
621
|
-
'height',
|
|
622
|
-
'marginheight',
|
|
623
|
-
'marginwidth',
|
|
624
|
-
'width'
|
|
625
|
-
],
|
|
626
|
-
img: [
|
|
627
|
-
'align',
|
|
628
|
-
'alt',
|
|
629
|
-
'border',
|
|
630
|
-
'height',
|
|
631
|
-
'hspace',
|
|
632
|
-
'ismap',
|
|
633
|
-
...(this._allowNamedProperties ? ['name'] : []),
|
|
634
|
-
'src',
|
|
635
|
-
'usemap',
|
|
636
|
-
'vspace',
|
|
637
|
-
'width'
|
|
638
|
-
],
|
|
639
|
-
input: [
|
|
640
|
-
'accept',
|
|
641
|
-
'accesskey',
|
|
642
|
-
'align',
|
|
643
|
-
'alt',
|
|
644
|
-
'autocomplete',
|
|
645
|
-
'checked',
|
|
646
|
-
'disabled',
|
|
647
|
-
'inputmode',
|
|
648
|
-
'ismap',
|
|
649
|
-
'list',
|
|
650
|
-
'max',
|
|
651
|
-
'maxlength',
|
|
652
|
-
'min',
|
|
653
|
-
'multiple',
|
|
654
|
-
...(this._allowNamedProperties ? ['name'] : []),
|
|
655
|
-
'placeholder',
|
|
656
|
-
'readonly',
|
|
657
|
-
'required',
|
|
658
|
-
'size',
|
|
659
|
-
'src',
|
|
660
|
-
'step',
|
|
661
|
-
'tabindex',
|
|
662
|
-
'type',
|
|
663
|
-
'usemap',
|
|
664
|
-
'value'
|
|
665
|
-
],
|
|
666
|
-
ins: ['cite', 'datetime'],
|
|
667
|
-
label: ['accesskey', 'for'],
|
|
668
|
-
legend: ['accesskey', 'align'],
|
|
669
|
-
li: ['type', 'value'],
|
|
670
|
-
map: this._allowNamedProperties ? ['name'] : [],
|
|
671
|
-
menu: ['compact', 'label', 'type'],
|
|
672
|
-
meter: ['high', 'low', 'max', 'min', 'value'],
|
|
673
|
-
ol: ['compact', 'reversed', 'start', 'type'],
|
|
674
|
-
optgroup: ['disabled', 'label'],
|
|
675
|
-
option: ['disabled', 'label', 'selected', 'value'],
|
|
676
|
-
output: ['for', ...(this._allowNamedProperties ? ['name'] : [])],
|
|
677
|
-
p: ['align'],
|
|
678
|
-
pre: ['width'],
|
|
679
|
-
progress: ['max', 'min', 'value'],
|
|
680
|
-
q: ['cite'],
|
|
681
|
-
select: [
|
|
682
|
-
'autocomplete',
|
|
683
|
-
'disabled',
|
|
684
|
-
'multiple',
|
|
685
|
-
...(this._allowNamedProperties ? ['name'] : []),
|
|
686
|
-
'required',
|
|
687
|
-
'size',
|
|
688
|
-
'tabindex'
|
|
689
|
-
],
|
|
690
|
-
source: ['type'],
|
|
691
|
-
table: [
|
|
692
|
-
'align',
|
|
693
|
-
'bgcolor',
|
|
694
|
-
'border',
|
|
695
|
-
'cellpadding',
|
|
696
|
-
'cellspacing',
|
|
697
|
-
'frame',
|
|
698
|
-
'rules',
|
|
699
|
-
'summary',
|
|
700
|
-
'width'
|
|
701
|
-
],
|
|
702
|
-
tbody: ['align', 'char', 'charoff', 'valign'],
|
|
703
|
-
td: [
|
|
704
|
-
'abbr',
|
|
705
|
-
'align',
|
|
706
|
-
'axis',
|
|
707
|
-
'bgcolor',
|
|
708
|
-
'char',
|
|
709
|
-
'charoff',
|
|
710
|
-
'colspan',
|
|
711
|
-
'headers',
|
|
712
|
-
'height',
|
|
713
|
-
'nowrap',
|
|
714
|
-
'rowspan',
|
|
715
|
-
'scope',
|
|
716
|
-
'valign',
|
|
717
|
-
'width'
|
|
718
|
-
],
|
|
719
|
-
textarea: [
|
|
720
|
-
'accesskey',
|
|
721
|
-
'autocomplete',
|
|
722
|
-
'cols',
|
|
723
|
-
'disabled',
|
|
724
|
-
'inputmode',
|
|
725
|
-
...(this._allowNamedProperties ? ['name'] : []),
|
|
726
|
-
'placeholder',
|
|
727
|
-
'readonly',
|
|
728
|
-
'required',
|
|
729
|
-
'rows',
|
|
730
|
-
'tabindex',
|
|
731
|
-
'wrap'
|
|
732
|
-
],
|
|
733
|
-
tfoot: ['align', 'char', 'charoff', 'valign'],
|
|
734
|
-
th: [
|
|
535
|
+
this._generateOptions = () => {
|
|
536
|
+
const schemesToAllow = Array.isArray(this._customAllowedSchemes)
|
|
537
|
+
? this._customAllowedSchemes
|
|
538
|
+
: [...sanitize.defaults.allowedSchemes];
|
|
539
|
+
return {
|
|
540
|
+
// HTML tags that are allowed to be used. Tags were extracted from Google Caja
|
|
541
|
+
allowedTags: [
|
|
542
|
+
'a',
|
|
735
543
|
'abbr',
|
|
736
|
-
'
|
|
737
|
-
'
|
|
738
|
-
'
|
|
739
|
-
'
|
|
740
|
-
'
|
|
544
|
+
'acronym',
|
|
545
|
+
'address',
|
|
546
|
+
'area',
|
|
547
|
+
'article',
|
|
548
|
+
'aside',
|
|
549
|
+
'audio',
|
|
550
|
+
'b',
|
|
551
|
+
'bdi',
|
|
552
|
+
'bdo',
|
|
553
|
+
'big',
|
|
554
|
+
'blockquote',
|
|
555
|
+
'br',
|
|
556
|
+
'button',
|
|
557
|
+
'canvas',
|
|
558
|
+
'caption',
|
|
559
|
+
'center',
|
|
560
|
+
'cite',
|
|
561
|
+
'code',
|
|
562
|
+
'col',
|
|
563
|
+
'colgroup',
|
|
741
564
|
'colspan',
|
|
742
|
-
'
|
|
743
|
-
'
|
|
744
|
-
'
|
|
565
|
+
'command',
|
|
566
|
+
'data',
|
|
567
|
+
'datalist',
|
|
568
|
+
'dd',
|
|
569
|
+
'del',
|
|
570
|
+
'details',
|
|
571
|
+
'dfn',
|
|
572
|
+
'dir',
|
|
573
|
+
'div',
|
|
574
|
+
'dl',
|
|
575
|
+
'dt',
|
|
576
|
+
'em',
|
|
577
|
+
'fieldset',
|
|
578
|
+
'figcaption',
|
|
579
|
+
'figure',
|
|
580
|
+
'font',
|
|
581
|
+
'footer',
|
|
582
|
+
'form',
|
|
583
|
+
'h1',
|
|
584
|
+
'h2',
|
|
585
|
+
'h3',
|
|
586
|
+
'h4',
|
|
587
|
+
'h5',
|
|
588
|
+
'h6',
|
|
589
|
+
'header',
|
|
590
|
+
'hgroup',
|
|
591
|
+
'hr',
|
|
592
|
+
'i',
|
|
593
|
+
// 'iframe' is allowed by Google Caja, but disallowed by default by sanitize-html
|
|
594
|
+
// , 'iframe'
|
|
595
|
+
'img',
|
|
596
|
+
'input',
|
|
597
|
+
'ins',
|
|
598
|
+
'kbd',
|
|
599
|
+
'label',
|
|
600
|
+
'legend',
|
|
601
|
+
'li',
|
|
602
|
+
'map',
|
|
603
|
+
'mark',
|
|
604
|
+
'menu',
|
|
605
|
+
'meter',
|
|
606
|
+
'nav',
|
|
607
|
+
'nobr',
|
|
608
|
+
'ol',
|
|
609
|
+
'optgroup',
|
|
610
|
+
'option',
|
|
611
|
+
'output',
|
|
612
|
+
'p',
|
|
613
|
+
'pre',
|
|
614
|
+
'progress',
|
|
615
|
+
'q',
|
|
745
616
|
'rowspan',
|
|
746
|
-
'
|
|
747
|
-
'
|
|
748
|
-
'
|
|
617
|
+
's',
|
|
618
|
+
'samp',
|
|
619
|
+
'section',
|
|
620
|
+
'select',
|
|
621
|
+
'small',
|
|
622
|
+
'source',
|
|
623
|
+
'span',
|
|
624
|
+
'strike',
|
|
625
|
+
'strong',
|
|
626
|
+
'sub',
|
|
627
|
+
'summary',
|
|
628
|
+
'sup',
|
|
629
|
+
'table',
|
|
630
|
+
'tbody',
|
|
631
|
+
'td',
|
|
632
|
+
'textarea',
|
|
633
|
+
'tfoot',
|
|
634
|
+
'th',
|
|
635
|
+
'thead',
|
|
636
|
+
'time',
|
|
637
|
+
'tr',
|
|
638
|
+
'track',
|
|
639
|
+
'tt',
|
|
640
|
+
'u',
|
|
641
|
+
'ul',
|
|
642
|
+
'var',
|
|
643
|
+
'video',
|
|
644
|
+
'wbr'
|
|
749
645
|
],
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
'
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
'
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
'
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
'
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
646
|
+
// Attributes that HTML tags are allowed to have, extracted from Google Caja.
|
|
647
|
+
// See https://github.com/jupyterlab/jupyterlab/issues/1812#issuecomment-285848435
|
|
648
|
+
allowedAttributes: {
|
|
649
|
+
'*': [
|
|
650
|
+
'class',
|
|
651
|
+
'data-jupyter-id',
|
|
652
|
+
'dir',
|
|
653
|
+
'draggable',
|
|
654
|
+
'hidden',
|
|
655
|
+
'id',
|
|
656
|
+
'inert',
|
|
657
|
+
'itemprop',
|
|
658
|
+
'itemref',
|
|
659
|
+
'itemscope',
|
|
660
|
+
'lang',
|
|
661
|
+
'spellcheck',
|
|
662
|
+
'style',
|
|
663
|
+
'title',
|
|
664
|
+
'translate'
|
|
665
|
+
],
|
|
666
|
+
// 'rel' and 'target' were *not* allowed by Google Caja
|
|
667
|
+
a: [
|
|
668
|
+
'accesskey',
|
|
669
|
+
'coords',
|
|
670
|
+
'href',
|
|
671
|
+
'hreflang',
|
|
672
|
+
...(this._allowNamedProperties ? ['name'] : []),
|
|
673
|
+
'rel',
|
|
674
|
+
'shape',
|
|
675
|
+
'tabindex',
|
|
676
|
+
'target',
|
|
677
|
+
'type'
|
|
678
|
+
],
|
|
679
|
+
area: [
|
|
680
|
+
'accesskey',
|
|
681
|
+
'alt',
|
|
682
|
+
'coords',
|
|
683
|
+
'href',
|
|
684
|
+
'nohref',
|
|
685
|
+
'shape',
|
|
686
|
+
'tabindex'
|
|
687
|
+
],
|
|
688
|
+
// 'autoplay' was *not* allowed by Google Caja
|
|
689
|
+
audio: [
|
|
690
|
+
'autoplay',
|
|
691
|
+
'controls',
|
|
692
|
+
'loop',
|
|
693
|
+
'mediagroup',
|
|
694
|
+
'muted',
|
|
695
|
+
'preload',
|
|
696
|
+
'src'
|
|
697
|
+
],
|
|
698
|
+
bdo: ['dir'],
|
|
699
|
+
blockquote: ['cite'],
|
|
700
|
+
br: ['clear'],
|
|
701
|
+
button: [
|
|
702
|
+
'accesskey',
|
|
703
|
+
'data-commandlinker-args',
|
|
704
|
+
'data-commandlinker-command',
|
|
705
|
+
'disabled',
|
|
706
|
+
...(this._allowNamedProperties ? ['name'] : []),
|
|
707
|
+
'tabindex',
|
|
708
|
+
'type',
|
|
709
|
+
'value'
|
|
710
|
+
],
|
|
711
|
+
canvas: ['height', 'width'],
|
|
712
|
+
caption: ['align'],
|
|
713
|
+
col: ['align', 'char', 'charoff', 'span', 'valign', 'width'],
|
|
714
|
+
colgroup: ['align', 'char', 'charoff', 'span', 'valign', 'width'],
|
|
715
|
+
command: [
|
|
716
|
+
'checked',
|
|
717
|
+
'command',
|
|
718
|
+
'disabled',
|
|
719
|
+
'icon',
|
|
720
|
+
'label',
|
|
721
|
+
'radiogroup',
|
|
722
|
+
'type'
|
|
723
|
+
],
|
|
724
|
+
data: ['value'],
|
|
725
|
+
del: ['cite', 'datetime'],
|
|
726
|
+
details: ['open'],
|
|
727
|
+
dir: ['compact'],
|
|
728
|
+
div: ['align'],
|
|
729
|
+
dl: ['compact'],
|
|
730
|
+
fieldset: ['disabled'],
|
|
731
|
+
font: ['color', 'face', 'size'],
|
|
732
|
+
form: [
|
|
733
|
+
'accept',
|
|
734
|
+
'autocomplete',
|
|
735
|
+
'enctype',
|
|
736
|
+
'method',
|
|
737
|
+
...(this._allowNamedProperties ? ['name'] : []),
|
|
738
|
+
'novalidate'
|
|
739
|
+
],
|
|
740
|
+
h1: ['align'],
|
|
741
|
+
h2: ['align'],
|
|
742
|
+
h3: ['align'],
|
|
743
|
+
h4: ['align'],
|
|
744
|
+
h5: ['align'],
|
|
745
|
+
h6: ['align'],
|
|
746
|
+
hr: ['align', 'noshade', 'size', 'width'],
|
|
747
|
+
iframe: [
|
|
748
|
+
'align',
|
|
749
|
+
'frameborder',
|
|
750
|
+
'height',
|
|
751
|
+
'marginheight',
|
|
752
|
+
'marginwidth',
|
|
753
|
+
'width'
|
|
754
|
+
],
|
|
755
|
+
img: [
|
|
756
|
+
'align',
|
|
757
|
+
'alt',
|
|
758
|
+
'border',
|
|
759
|
+
'height',
|
|
760
|
+
'hspace',
|
|
761
|
+
'ismap',
|
|
762
|
+
...(this._allowNamedProperties ? ['name'] : []),
|
|
763
|
+
'src',
|
|
764
|
+
'usemap',
|
|
765
|
+
'vspace',
|
|
766
|
+
'width'
|
|
767
|
+
],
|
|
768
|
+
input: [
|
|
769
|
+
'accept',
|
|
770
|
+
'accesskey',
|
|
771
|
+
'align',
|
|
772
|
+
'alt',
|
|
773
|
+
'autocomplete',
|
|
774
|
+
'checked',
|
|
775
|
+
'disabled',
|
|
776
|
+
'inputmode',
|
|
777
|
+
'ismap',
|
|
778
|
+
'list',
|
|
779
|
+
'max',
|
|
780
|
+
'maxlength',
|
|
781
|
+
'min',
|
|
782
|
+
'multiple',
|
|
783
|
+
...(this._allowNamedProperties ? ['name'] : []),
|
|
784
|
+
'placeholder',
|
|
785
|
+
'readonly',
|
|
786
|
+
'required',
|
|
787
|
+
'size',
|
|
788
|
+
'src',
|
|
789
|
+
'step',
|
|
790
|
+
'tabindex',
|
|
791
|
+
'type',
|
|
792
|
+
'usemap',
|
|
793
|
+
'value'
|
|
794
|
+
],
|
|
795
|
+
ins: ['cite', 'datetime'],
|
|
796
|
+
label: ['accesskey', 'for'],
|
|
797
|
+
legend: ['accesskey', 'align'],
|
|
798
|
+
li: ['type', 'value'],
|
|
799
|
+
map: this._allowNamedProperties ? ['name'] : [],
|
|
800
|
+
menu: ['compact', 'label', 'type'],
|
|
801
|
+
meter: ['high', 'low', 'max', 'min', 'value'],
|
|
802
|
+
ol: ['compact', 'reversed', 'start', 'type'],
|
|
803
|
+
optgroup: ['disabled', 'label'],
|
|
804
|
+
option: ['disabled', 'label', 'selected', 'value'],
|
|
805
|
+
output: ['for', ...(this._allowNamedProperties ? ['name'] : [])],
|
|
806
|
+
p: ['align'],
|
|
807
|
+
pre: ['width'],
|
|
808
|
+
progress: ['max', 'min', 'value'],
|
|
809
|
+
q: ['cite'],
|
|
810
|
+
select: [
|
|
811
|
+
'autocomplete',
|
|
812
|
+
'disabled',
|
|
813
|
+
'multiple',
|
|
814
|
+
...(this._allowNamedProperties ? ['name'] : []),
|
|
815
|
+
'required',
|
|
816
|
+
'size',
|
|
817
|
+
'tabindex'
|
|
818
|
+
],
|
|
819
|
+
source: ['type'],
|
|
820
|
+
table: [
|
|
821
|
+
'align',
|
|
822
|
+
'bgcolor',
|
|
823
|
+
'border',
|
|
824
|
+
'cellpadding',
|
|
825
|
+
'cellspacing',
|
|
826
|
+
'frame',
|
|
827
|
+
'rules',
|
|
828
|
+
'summary',
|
|
829
|
+
'width'
|
|
830
|
+
],
|
|
831
|
+
tbody: ['align', 'char', 'charoff', 'valign'],
|
|
832
|
+
td: [
|
|
833
|
+
'abbr',
|
|
834
|
+
'align',
|
|
835
|
+
'axis',
|
|
836
|
+
'bgcolor',
|
|
837
|
+
'char',
|
|
838
|
+
'charoff',
|
|
839
|
+
'colspan',
|
|
840
|
+
'headers',
|
|
841
|
+
'height',
|
|
842
|
+
'nowrap',
|
|
843
|
+
'rowspan',
|
|
844
|
+
'scope',
|
|
845
|
+
'valign',
|
|
846
|
+
'width'
|
|
847
|
+
],
|
|
848
|
+
textarea: [
|
|
849
|
+
'accesskey',
|
|
850
|
+
'autocomplete',
|
|
851
|
+
'cols',
|
|
852
|
+
'disabled',
|
|
853
|
+
'inputmode',
|
|
854
|
+
...(this._allowNamedProperties ? ['name'] : []),
|
|
855
|
+
'placeholder',
|
|
856
|
+
'readonly',
|
|
857
|
+
'required',
|
|
858
|
+
'rows',
|
|
859
|
+
'tabindex',
|
|
860
|
+
'wrap'
|
|
861
|
+
],
|
|
862
|
+
tfoot: ['align', 'char', 'charoff', 'valign'],
|
|
863
|
+
th: [
|
|
864
|
+
'abbr',
|
|
865
|
+
'align',
|
|
866
|
+
'axis',
|
|
867
|
+
'bgcolor',
|
|
868
|
+
'char',
|
|
869
|
+
'charoff',
|
|
870
|
+
'colspan',
|
|
871
|
+
'headers',
|
|
872
|
+
'height',
|
|
873
|
+
'nowrap',
|
|
874
|
+
'rowspan',
|
|
875
|
+
'scope',
|
|
876
|
+
'valign',
|
|
877
|
+
'width'
|
|
878
|
+
],
|
|
879
|
+
thead: ['align', 'char', 'charoff', 'valign'],
|
|
880
|
+
tr: ['align', 'bgcolor', 'char', 'charoff', 'valign'],
|
|
881
|
+
track: ['default', 'kind', 'label', 'srclang'],
|
|
882
|
+
ul: ['compact', 'type'],
|
|
883
|
+
video: [
|
|
884
|
+
'autoplay',
|
|
885
|
+
'controls',
|
|
886
|
+
'height',
|
|
887
|
+
'loop',
|
|
888
|
+
'mediagroup',
|
|
889
|
+
'muted',
|
|
890
|
+
'poster',
|
|
891
|
+
'preload',
|
|
892
|
+
'src',
|
|
893
|
+
'width'
|
|
894
|
+
]
|
|
895
|
+
},
|
|
896
|
+
// Inline CSS styles that HTML tags may have (and their allowed values)
|
|
897
|
+
allowedStyles: {
|
|
898
|
+
// To simplify the data, all styles are allowed on all tags that allow the style attribute
|
|
899
|
+
'*': {
|
|
900
|
+
'backface-visibility': [CssProp.BACKFACE_VISIBILITY],
|
|
901
|
+
background: [CssProp.BACKGROUND],
|
|
902
|
+
'background-attachment': [CssProp.BACKGROUND_ATTACHMENT],
|
|
903
|
+
'background-clip': [CssProp.BACKGROUND_CLIP],
|
|
904
|
+
'background-color': [CssProp.BACKGROUND_COLOR],
|
|
905
|
+
'background-image': [CssProp.BACKGROUND_IMAGE],
|
|
906
|
+
'background-origin': [CssProp.BACKGROUND_ORIGIN],
|
|
907
|
+
'background-position': [CssProp.BACKGROUND_POSITION],
|
|
908
|
+
'background-repeat': [CssProp.BACKGROUND_REPEAT],
|
|
909
|
+
'background-size': [CssProp.BACKGROUND_SIZE],
|
|
910
|
+
border: [CssProp.BORDER],
|
|
911
|
+
'border-bottom': [CssProp.BORDER_BOTTOM],
|
|
912
|
+
'border-bottom-color': [CssProp.BORDER_BOTTOM_COLOR],
|
|
913
|
+
'border-bottom-left-radius': [CssProp.BORDER_BOTTOM_LEFT_RADIUS],
|
|
914
|
+
'border-bottom-right-radius': [CssProp.BORDER_BOTTOM_RIGHT_RADIUS],
|
|
915
|
+
'border-bottom-style': [CssProp.BORDER_BOTTOM_STYLE],
|
|
916
|
+
'border-bottom-width': [CssProp.BORDER_BOTTOM_WIDTH],
|
|
917
|
+
'border-collapse': [CssProp.BORDER_COLLAPSE],
|
|
918
|
+
'border-color': [CssProp.BORDER_COLOR],
|
|
919
|
+
'border-left': [CssProp.BORDER_LEFT],
|
|
920
|
+
'border-left-color': [CssProp.BORDER_LEFT_COLOR],
|
|
921
|
+
'border-left-style': [CssProp.BORDER_LEFT_STYLE],
|
|
922
|
+
'border-left-width': [CssProp.BORDER_LEFT_WIDTH],
|
|
923
|
+
'border-radius': [CssProp.BORDER_RADIUS],
|
|
924
|
+
'border-right': [CssProp.BORDER_RIGHT],
|
|
925
|
+
'border-right-color': [CssProp.BORDER_RIGHT_COLOR],
|
|
926
|
+
'border-right-style': [CssProp.BORDER_RIGHT_STYLE],
|
|
927
|
+
'border-right-width': [CssProp.BORDER_RIGHT_WIDTH],
|
|
928
|
+
'border-spacing': [CssProp.BORDER_SPACING],
|
|
929
|
+
'border-style': [CssProp.BORDER_STYLE],
|
|
930
|
+
'border-top': [CssProp.BORDER_TOP],
|
|
931
|
+
'border-top-color': [CssProp.BORDER_TOP_COLOR],
|
|
932
|
+
'border-top-left-radius': [CssProp.BORDER_TOP_LEFT_RADIUS],
|
|
933
|
+
'border-top-right-radius': [CssProp.BORDER_TOP_RIGHT_RADIUS],
|
|
934
|
+
'border-top-style': [CssProp.BORDER_TOP_STYLE],
|
|
935
|
+
'border-top-width': [CssProp.BORDER_TOP_WIDTH],
|
|
936
|
+
'border-width': [CssProp.BORDER_WIDTH],
|
|
937
|
+
bottom: [CssProp.BOTTOM],
|
|
938
|
+
box: [CssProp.BOX],
|
|
939
|
+
'box-shadow': [CssProp.BOX_SHADOW],
|
|
940
|
+
'box-sizing': [CssProp.BOX_SIZING],
|
|
941
|
+
'caption-side': [CssProp.CAPTION_SIDE],
|
|
942
|
+
clear: [CssProp.CLEAR],
|
|
943
|
+
clip: [CssProp.CLIP],
|
|
944
|
+
color: [CssProp.COLOR],
|
|
945
|
+
cursor: [CssProp.CURSOR],
|
|
946
|
+
direction: [CssProp.DIRECTION],
|
|
947
|
+
display: [CssProp.DISPLAY],
|
|
948
|
+
'display-inside': [CssProp.DISPLAY_INSIDE],
|
|
949
|
+
'display-outside': [CssProp.DISPLAY_OUTSIDE],
|
|
950
|
+
elevation: [CssProp.ELEVATION],
|
|
951
|
+
'empty-cells': [CssProp.EMPTY_CELLS],
|
|
952
|
+
float: [CssProp.FLOAT],
|
|
953
|
+
font: [CssProp.FONT],
|
|
954
|
+
'font-family': [CssProp.FONT_FAMILY],
|
|
955
|
+
'font-size': [CssProp.FONT_SIZE],
|
|
956
|
+
'font-stretch': [CssProp.FONT_STRETCH],
|
|
957
|
+
'font-style': [CssProp.FONT_STYLE],
|
|
958
|
+
'font-variant': [CssProp.FONT_VARIANT],
|
|
959
|
+
'font-weight': [CssProp.FONT_WEIGHT],
|
|
960
|
+
height: [CssProp.HEIGHT],
|
|
961
|
+
left: [CssProp.LEFT],
|
|
962
|
+
'letter-spacing': [CssProp.LETTER_SPACING],
|
|
963
|
+
'line-height': [CssProp.LINE_HEIGHT],
|
|
964
|
+
'list-style': [CssProp.LIST_STYLE],
|
|
965
|
+
'list-style-image': [CssProp.LIST_STYLE_IMAGE],
|
|
966
|
+
'list-style-position': [CssProp.LIST_STYLE_POSITION],
|
|
967
|
+
'list-style-type': [CssProp.LIST_STYLE_TYPE],
|
|
968
|
+
margin: [CssProp.MARGIN],
|
|
969
|
+
'margin-bottom': [CssProp.MARGIN_BOTTOM],
|
|
970
|
+
'margin-left': [CssProp.MARGIN_LEFT],
|
|
971
|
+
'margin-right': [CssProp.MARGIN_RIGHT],
|
|
972
|
+
'margin-top': [CssProp.MARGIN_TOP],
|
|
973
|
+
'max-height': [CssProp.MAX_HEIGHT],
|
|
974
|
+
'max-width': [CssProp.MAX_WIDTH],
|
|
975
|
+
'min-height': [CssProp.MIN_HEIGHT],
|
|
976
|
+
'min-width': [CssProp.MIN_WIDTH],
|
|
977
|
+
opacity: [CssProp.OPACITY],
|
|
978
|
+
outline: [CssProp.OUTLINE],
|
|
979
|
+
'outline-color': [CssProp.OUTLINE_COLOR],
|
|
980
|
+
'outline-style': [CssProp.OUTLINE_STYLE],
|
|
981
|
+
'outline-width': [CssProp.OUTLINE_WIDTH],
|
|
982
|
+
overflow: [CssProp.OVERFLOW],
|
|
983
|
+
'overflow-wrap': [CssProp.OVERFLOW_WRAP],
|
|
984
|
+
'overflow-x': [CssProp.OVERFLOW_X],
|
|
985
|
+
'overflow-y': [CssProp.OVERFLOW_Y],
|
|
986
|
+
padding: [CssProp.PADDING],
|
|
987
|
+
'padding-bottom': [CssProp.PADDING_BOTTOM],
|
|
988
|
+
'padding-left': [CssProp.PADDING_LEFT],
|
|
989
|
+
'padding-right': [CssProp.PADDING_RIGHT],
|
|
990
|
+
'padding-top': [CssProp.PADDING_TOP],
|
|
991
|
+
'page-break-after': [CssProp.PAGE_BREAK_AFTER],
|
|
992
|
+
'page-break-before': [CssProp.PAGE_BREAK_BEFORE],
|
|
993
|
+
'page-break-inside': [CssProp.PAGE_BREAK_INSIDE],
|
|
994
|
+
'pause-after': [CssProp.PAUSE_AFTER],
|
|
995
|
+
perspective: [CssProp.PERSPECTIVE],
|
|
996
|
+
pitch: [CssProp.PITCH],
|
|
997
|
+
'pitch-range': [CssProp.PITCH_RANGE],
|
|
998
|
+
position: [CssProp.POSITION],
|
|
999
|
+
quotes: [CssProp.QUOTES],
|
|
1000
|
+
resize: [CssProp.RESIZE],
|
|
1001
|
+
richness: [CssProp.RICHNESS],
|
|
1002
|
+
right: [CssProp.RIGHT],
|
|
1003
|
+
speak: [CssProp.SPEAK],
|
|
1004
|
+
'speak-header': [CssProp.SPEAK_HEADER],
|
|
1005
|
+
'speak-numeral': [CssProp.SPEAK_NUMERAL],
|
|
1006
|
+
'speak-punctuation': [CssProp.SPEAK_PUNCTUATION],
|
|
1007
|
+
'speech-rate': [CssProp.SPEECH_RATE],
|
|
1008
|
+
stress: [CssProp.STRESS],
|
|
1009
|
+
'table-layout': [CssProp.TABLE_LAYOUT],
|
|
1010
|
+
'text-align': [CssProp.TEXT_ALIGN],
|
|
1011
|
+
'text-decoration': [CssProp.TEXT_DECORATION],
|
|
1012
|
+
'text-indent': [CssProp.TEXT_INDENT],
|
|
1013
|
+
'text-overflow': [CssProp.TEXT_OVERFLOW],
|
|
1014
|
+
'text-shadow': [CssProp.TEXT_SHADOW],
|
|
1015
|
+
'text-transform': [CssProp.TEXT_TRANSFORM],
|
|
1016
|
+
'text-wrap': [CssProp.TEXT_WRAP],
|
|
1017
|
+
top: [CssProp.TOP],
|
|
1018
|
+
'unicode-bidi': [CssProp.UNICODE_BIDI],
|
|
1019
|
+
'vertical-align': [CssProp.VERTICAL_ALIGN],
|
|
1020
|
+
visibility: [CssProp.VISIBILITY],
|
|
1021
|
+
volume: [CssProp.VOLUME],
|
|
1022
|
+
'white-space': [CssProp.WHITE_SPACE],
|
|
1023
|
+
width: [CssProp.WIDTH],
|
|
1024
|
+
'word-break': [CssProp.WORD_BREAK],
|
|
1025
|
+
'word-spacing': [CssProp.WORD_SPACING],
|
|
1026
|
+
'word-wrap': [CssProp.WORD_WRAP],
|
|
1027
|
+
'z-index': [CssProp.Z_INDEX],
|
|
1028
|
+
zoom: [CssProp.ZOOM],
|
|
1029
|
+
// Flexbox and Grid properties
|
|
1030
|
+
'align-content': [CssProp.ALIGN_CONTENT],
|
|
1031
|
+
'align-items': [CssProp.ALIGN_ITEMS],
|
|
1032
|
+
'align-self': [CssProp.ALIGN_SELF],
|
|
1033
|
+
flex: [CssProp.FLEX],
|
|
1034
|
+
'flex-basis': [CssProp.FLEX_BASIS],
|
|
1035
|
+
'flex-direction': [CssProp.FLEX_DIRECTION],
|
|
1036
|
+
'flex-grow': [CssProp.FLEX_GROW],
|
|
1037
|
+
'flex-shrink': [CssProp.FLEX_SHRINK],
|
|
1038
|
+
'flex-wrap': [CssProp.FLEX_WRAP],
|
|
1039
|
+
grid: [CssProp.GRID],
|
|
1040
|
+
'grid-area': [CssProp.GRID_AREA],
|
|
1041
|
+
'grid-auto-columns': [CssProp.GRID_AUTO_COLUMNS],
|
|
1042
|
+
'grid-auto-flow': [CssProp.GRID_AUTO_FLOW],
|
|
1043
|
+
'grid-auto-rows': [CssProp.GRID_AUTO_ROWS],
|
|
1044
|
+
'grid-column': [CssProp.GRID_COLUMN],
|
|
1045
|
+
'grid-column-end': [CssProp.GRID_COLUMN_END],
|
|
1046
|
+
'grid-column-gap': [CssProp.GRID_COLUMN_GAP],
|
|
1047
|
+
'grid-column-start': [CssProp.GRID_COLUMN_START],
|
|
1048
|
+
'grid-gap': [CssProp.GRID_GAP],
|
|
1049
|
+
'grid-row': [CssProp.GRID_ROW],
|
|
1050
|
+
'grid-row-end': [CssProp.GRID_ROW_END],
|
|
1051
|
+
'grid-row-gap': [CssProp.GRID_ROW_GAP],
|
|
1052
|
+
'grid-row-start': [CssProp.GRID_ROW_START],
|
|
1053
|
+
'grid-template': [CssProp.GRID_TEMPLATE],
|
|
1054
|
+
'grid-template-areas': [CssProp.GRID_TEMPLATE_AREAS],
|
|
1055
|
+
'grid-template-columns': [CssProp.GRID_TEMPLATE_COLUMNS],
|
|
1056
|
+
'grid-template-rows': [CssProp.GRID_TEMPLATE_ROWS],
|
|
1057
|
+
gap: [CssProp.GAP],
|
|
1058
|
+
'row-gap': [CssProp.ROW_GAP],
|
|
1059
|
+
'column-gap': [CssProp.COLUMN_GAP],
|
|
1060
|
+
'justify-content': [CssProp.JUSTIFY_CONTENT],
|
|
1061
|
+
'justify-items': [CssProp.JUSTIFY_ITEMS],
|
|
1062
|
+
'justify-self': [CssProp.JUSTIFY_SELF],
|
|
1063
|
+
order: [CssProp.ORDER],
|
|
1064
|
+
'place-content': [CssProp.PLACE_CONTENT],
|
|
1065
|
+
'place-items': [CssProp.PLACE_ITEMS],
|
|
1066
|
+
'place-self': [CssProp.PLACE_SELF]
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
transformTags: {
|
|
1070
|
+
// Set the "rel" attribute for <a> tags to "nofollow".
|
|
1071
|
+
a: sanitize.simpleTransform('a', { rel: 'nofollow' }),
|
|
1072
|
+
// Set the "disabled" attribute for <input> tags.
|
|
1073
|
+
input: sanitize.simpleTransform('input', { disabled: 'disabled' }),
|
|
1074
|
+
// Replace "id" attribute by "data-jupyter-id" if "id" is not allowed.
|
|
1075
|
+
...(this._allowNamedProperties
|
|
1076
|
+
? {}
|
|
1077
|
+
: {
|
|
1078
|
+
'*': function (tagName, attribs) {
|
|
1079
|
+
if (attribs.id !== undefined) {
|
|
1080
|
+
attribs['data-jupyter-id'] = attribs.id;
|
|
1081
|
+
delete attribs.id;
|
|
1082
|
+
}
|
|
1083
|
+
return {
|
|
1084
|
+
tagName,
|
|
1085
|
+
attribs: {
|
|
1086
|
+
...attribs
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
})
|
|
1091
|
+
},
|
|
1092
|
+
allowedSchemes: schemesToAllow,
|
|
1093
|
+
allowedSchemesByTag: {
|
|
1094
|
+
// Allow 'attachment:' img src (used for markdown cell attachments).
|
|
1095
|
+
img: [...schemesToAllow, 'attachment']
|
|
1096
|
+
},
|
|
1097
|
+
// Override of the default option, so we can skip 'src' attribute validation.
|
|
1098
|
+
// 'src' Attributes are validated to be URIs, which does not allow for embedded (image) data.
|
|
1099
|
+
// Since embedded data is no longer deemed to be a threat, validation can be skipped.
|
|
1100
|
+
// See https://github.com/jupyterlab/jupyterlab/issues/5183
|
|
1101
|
+
allowedSchemesAppliedToAttributes: ['href', 'cite']
|
|
1102
|
+
};
|
|
1103
|
+
};
|
|
919
1104
|
this._options = this._generateOptions();
|
|
920
1105
|
}
|
|
921
1106
|
/**
|
|
@@ -936,14 +1121,23 @@ export class Sanitizer {
|
|
|
936
1121
|
getAutolink() {
|
|
937
1122
|
return this._autolink;
|
|
938
1123
|
}
|
|
1124
|
+
/**
|
|
1125
|
+
* @returns Whether to allow name and id attributes.
|
|
1126
|
+
*/
|
|
1127
|
+
get allowNamedProperties() {
|
|
1128
|
+
return this._allowNamedProperties;
|
|
1129
|
+
}
|
|
939
1130
|
/**
|
|
940
1131
|
* Set the allowed schemes
|
|
941
1132
|
*
|
|
942
|
-
* @param scheme Allowed schemes
|
|
1133
|
+
* @param scheme Allowed schemes.
|
|
1134
|
+
* Automatically regenerates sanitizer options to apply the change.
|
|
1135
|
+
* Note: the schemes merge into the current config and does not get overwritten.
|
|
943
1136
|
*/
|
|
944
1137
|
setAllowedSchemes(scheme) {
|
|
945
1138
|
// Force copy of `scheme`
|
|
946
|
-
this.
|
|
1139
|
+
this._customAllowedSchemes = [...scheme];
|
|
1140
|
+
this._options = this._generateOptions();
|
|
947
1141
|
}
|
|
948
1142
|
/**
|
|
949
1143
|
* Set the URL replacement boolean.
|