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