@jupyterlab/apputils 4.4.7 → 4.4.8

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
@@ -460,11 +460,14 @@ export class Sanitizer implements IRenderMime.ISanitizer {
460
460
  /**
461
461
  * Set the allowed schemes
462
462
  *
463
- * @param scheme Allowed schemes
463
+ * @param scheme Allowed schemes.
464
+ * Automatically regenerates sanitizer options to apply the change.
465
+ * Note: the schemes merge into the current config and does not get overwritten.
464
466
  */
465
467
  setAllowedSchemes(scheme: Array<string>): void {
466
468
  // Force copy of `scheme`
467
- this._options.allowedSchemes = [...scheme];
469
+ this._customAllowedSchemes = [...scheme];
470
+ this._options = this._generateOptions();
468
471
  }
469
472
 
470
473
  /**
@@ -486,513 +489,520 @@ export class Sanitizer implements IRenderMime.ISanitizer {
486
489
 
487
490
  private _autolink: boolean = true;
488
491
  private _allowNamedProperties: boolean = false;
492
+ private _customAllowedSchemes: string[] | undefined;
489
493
  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: [
494
+ private _generateOptions = (): sanitize.IOptions => {
495
+ const schemesToAllow = Array.isArray(this._customAllowedSchemes)
496
+ ? this._customAllowedSchemes
497
+ : [...sanitize.defaults.allowedSchemes];
498
+
499
+ return {
500
+ // HTML tags that are allowed to be used. Tags were extracted from Google Caja
501
+ allowedTags: [
502
+ 'a',
814
503
  'abbr',
815
- 'align',
816
- 'axis',
817
- 'bgcolor',
818
- 'char',
819
- 'charoff',
504
+ 'acronym',
505
+ 'address',
506
+ 'area',
507
+ 'article',
508
+ 'aside',
509
+ 'audio',
510
+ 'b',
511
+ 'bdi',
512
+ 'bdo',
513
+ 'big',
514
+ 'blockquote',
515
+ 'br',
516
+ 'button',
517
+ 'canvas',
518
+ 'caption',
519
+ 'center',
520
+ 'cite',
521
+ 'code',
522
+ 'col',
523
+ 'colgroup',
820
524
  'colspan',
821
- 'headers',
822
- 'height',
823
- 'nowrap',
525
+ 'command',
526
+ 'data',
527
+ 'datalist',
528
+ 'dd',
529
+ 'del',
530
+ 'details',
531
+ 'dfn',
532
+ 'dir',
533
+ 'div',
534
+ 'dl',
535
+ 'dt',
536
+ 'em',
537
+ 'fieldset',
538
+ 'figcaption',
539
+ 'figure',
540
+ 'font',
541
+ 'footer',
542
+ 'form',
543
+ 'h1',
544
+ 'h2',
545
+ 'h3',
546
+ 'h4',
547
+ 'h5',
548
+ 'h6',
549
+ 'header',
550
+ 'hgroup',
551
+ 'hr',
552
+ 'i',
553
+ // 'iframe' is allowed by Google Caja, but disallowed by default by sanitize-html
554
+ // , 'iframe'
555
+ 'img',
556
+ 'input',
557
+ 'ins',
558
+ 'kbd',
559
+ 'label',
560
+ 'legend',
561
+ 'li',
562
+ 'map',
563
+ 'mark',
564
+ 'menu',
565
+ 'meter',
566
+ 'nav',
567
+ 'nobr',
568
+ 'ol',
569
+ 'optgroup',
570
+ 'option',
571
+ 'output',
572
+ 'p',
573
+ 'pre',
574
+ 'progress',
575
+ 'q',
824
576
  'rowspan',
825
- 'scope',
826
- 'valign',
827
- 'width'
577
+ 's',
578
+ 'samp',
579
+ 'section',
580
+ 'select',
581
+ 'small',
582
+ 'source',
583
+ 'span',
584
+ 'strike',
585
+ 'strong',
586
+ 'sub',
587
+ 'summary',
588
+ 'sup',
589
+ 'table',
590
+ 'tbody',
591
+ 'td',
592
+ 'textarea',
593
+ 'tfoot',
594
+ 'th',
595
+ 'thead',
596
+ 'time',
597
+ 'tr',
598
+ 'track',
599
+ 'tt',
600
+ 'u',
601
+ 'ul',
602
+ 'var',
603
+ 'video',
604
+ 'wbr'
828
605
  ],
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
- });
606
+ // Attributes that HTML tags are allowed to have, extracted from Google Caja.
607
+ // See https://github.com/jupyterlab/jupyterlab/issues/1812#issuecomment-285848435
608
+ allowedAttributes: {
609
+ '*': [
610
+ 'class',
611
+ 'dir',
612
+ 'draggable',
613
+ 'hidden',
614
+ ...(this._allowNamedProperties ? ['id'] : []),
615
+ 'inert',
616
+ 'itemprop',
617
+ 'itemref',
618
+ 'itemscope',
619
+ 'lang',
620
+ 'spellcheck',
621
+ 'style',
622
+ 'title',
623
+ 'translate'
624
+ ],
625
+ // 'rel' and 'target' were *not* allowed by Google Caja
626
+ a: [
627
+ 'accesskey',
628
+ 'coords',
629
+ 'href',
630
+ 'hreflang',
631
+ ...(this._allowNamedProperties ? ['name'] : []),
632
+ 'rel',
633
+ 'shape',
634
+ 'tabindex',
635
+ 'target',
636
+ 'type'
637
+ ],
638
+ area: [
639
+ 'accesskey',
640
+ 'alt',
641
+ 'coords',
642
+ 'href',
643
+ 'nohref',
644
+ 'shape',
645
+ 'tabindex'
646
+ ],
647
+ // 'autoplay' was *not* allowed by Google Caja
648
+ audio: [
649
+ 'autoplay',
650
+ 'controls',
651
+ 'loop',
652
+ 'mediagroup',
653
+ 'muted',
654
+ 'preload',
655
+ 'src'
656
+ ],
657
+ bdo: ['dir'],
658
+ blockquote: ['cite'],
659
+ br: ['clear'],
660
+ button: [
661
+ 'accesskey',
662
+ 'data-commandlinker-args',
663
+ 'data-commandlinker-command',
664
+ 'disabled',
665
+ ...(this._allowNamedProperties ? ['name'] : []),
666
+ 'tabindex',
667
+ 'type',
668
+ 'value'
669
+ ],
670
+ canvas: ['height', 'width'],
671
+ caption: ['align'],
672
+ col: ['align', 'char', 'charoff', 'span', 'valign', 'width'],
673
+ colgroup: ['align', 'char', 'charoff', 'span', 'valign', 'width'],
674
+ command: [
675
+ 'checked',
676
+ 'command',
677
+ 'disabled',
678
+ 'icon',
679
+ 'label',
680
+ 'radiogroup',
681
+ 'type'
682
+ ],
683
+ data: ['value'],
684
+ del: ['cite', 'datetime'],
685
+ details: ['open'],
686
+ dir: ['compact'],
687
+ div: ['align'],
688
+ dl: ['compact'],
689
+ fieldset: ['disabled'],
690
+ font: ['color', 'face', 'size'],
691
+ form: [
692
+ 'accept',
693
+ 'autocomplete',
694
+ 'enctype',
695
+ 'method',
696
+ ...(this._allowNamedProperties ? ['name'] : []),
697
+ 'novalidate'
698
+ ],
699
+ h1: ['align'],
700
+ h2: ['align'],
701
+ h3: ['align'],
702
+ h4: ['align'],
703
+ h5: ['align'],
704
+ h6: ['align'],
705
+ hr: ['align', 'noshade', 'size', 'width'],
706
+ iframe: [
707
+ 'align',
708
+ 'frameborder',
709
+ 'height',
710
+ 'marginheight',
711
+ 'marginwidth',
712
+ 'width'
713
+ ],
714
+ img: [
715
+ 'align',
716
+ 'alt',
717
+ 'border',
718
+ 'height',
719
+ 'hspace',
720
+ 'ismap',
721
+ ...(this._allowNamedProperties ? ['name'] : []),
722
+ 'src',
723
+ 'usemap',
724
+ 'vspace',
725
+ 'width'
726
+ ],
727
+ input: [
728
+ 'accept',
729
+ 'accesskey',
730
+ 'align',
731
+ 'alt',
732
+ 'autocomplete',
733
+ 'checked',
734
+ 'disabled',
735
+ 'inputmode',
736
+ 'ismap',
737
+ 'list',
738
+ 'max',
739
+ 'maxlength',
740
+ 'min',
741
+ 'multiple',
742
+ ...(this._allowNamedProperties ? ['name'] : []),
743
+ 'placeholder',
744
+ 'readonly',
745
+ 'required',
746
+ 'size',
747
+ 'src',
748
+ 'step',
749
+ 'tabindex',
750
+ 'type',
751
+ 'usemap',
752
+ 'value'
753
+ ],
754
+ ins: ['cite', 'datetime'],
755
+ label: ['accesskey', 'for'],
756
+ legend: ['accesskey', 'align'],
757
+ li: ['type', 'value'],
758
+ map: this._allowNamedProperties ? ['name'] : [],
759
+ menu: ['compact', 'label', 'type'],
760
+ meter: ['high', 'low', 'max', 'min', 'value'],
761
+ ol: ['compact', 'reversed', 'start', 'type'],
762
+ optgroup: ['disabled', 'label'],
763
+ option: ['disabled', 'label', 'selected', 'value'],
764
+ output: ['for', ...(this._allowNamedProperties ? ['name'] : [])],
765
+ p: ['align'],
766
+ pre: ['width'],
767
+ progress: ['max', 'min', 'value'],
768
+ q: ['cite'],
769
+ select: [
770
+ 'autocomplete',
771
+ 'disabled',
772
+ 'multiple',
773
+ ...(this._allowNamedProperties ? ['name'] : []),
774
+ 'required',
775
+ 'size',
776
+ 'tabindex'
777
+ ],
778
+ source: ['type'],
779
+ table: [
780
+ 'align',
781
+ 'bgcolor',
782
+ 'border',
783
+ 'cellpadding',
784
+ 'cellspacing',
785
+ 'frame',
786
+ 'rules',
787
+ 'summary',
788
+ 'width'
789
+ ],
790
+ tbody: ['align', 'char', 'charoff', 'valign'],
791
+ td: [
792
+ 'abbr',
793
+ 'align',
794
+ 'axis',
795
+ 'bgcolor',
796
+ 'char',
797
+ 'charoff',
798
+ 'colspan',
799
+ 'headers',
800
+ 'height',
801
+ 'nowrap',
802
+ 'rowspan',
803
+ 'scope',
804
+ 'valign',
805
+ 'width'
806
+ ],
807
+ textarea: [
808
+ 'accesskey',
809
+ 'autocomplete',
810
+ 'cols',
811
+ 'disabled',
812
+ 'inputmode',
813
+ ...(this._allowNamedProperties ? ['name'] : []),
814
+ 'placeholder',
815
+ 'readonly',
816
+ 'required',
817
+ 'rows',
818
+ 'tabindex',
819
+ 'wrap'
820
+ ],
821
+ tfoot: ['align', 'char', 'charoff', 'valign'],
822
+ th: [
823
+ 'abbr',
824
+ 'align',
825
+ 'axis',
826
+ 'bgcolor',
827
+ 'char',
828
+ 'charoff',
829
+ 'colspan',
830
+ 'headers',
831
+ 'height',
832
+ 'nowrap',
833
+ 'rowspan',
834
+ 'scope',
835
+ 'valign',
836
+ 'width'
837
+ ],
838
+ thead: ['align', 'char', 'charoff', 'valign'],
839
+ tr: ['align', 'bgcolor', 'char', 'charoff', 'valign'],
840
+ track: ['default', 'kind', 'label', 'srclang'],
841
+ ul: ['compact', 'type'],
842
+ video: [
843
+ 'autoplay',
844
+ 'controls',
845
+ 'height',
846
+ 'loop',
847
+ 'mediagroup',
848
+ 'muted',
849
+ 'poster',
850
+ 'preload',
851
+ 'src',
852
+ 'width'
853
+ ]
854
+ },
855
+ // Inline CSS styles that HTML tags may have (and their allowed values)
856
+ allowedStyles: {
857
+ // To simplify the data, all styles are allowed on all tags that allow the style attribute
858
+ '*': {
859
+ 'backface-visibility': [CssProp.BACKFACE_VISIBILITY],
860
+ background: [CssProp.BACKGROUND],
861
+ 'background-attachment': [CssProp.BACKGROUND_ATTACHMENT],
862
+ 'background-clip': [CssProp.BACKGROUND_CLIP],
863
+ 'background-color': [CssProp.BACKGROUND_COLOR],
864
+ 'background-image': [CssProp.BACKGROUND_IMAGE],
865
+ 'background-origin': [CssProp.BACKGROUND_ORIGIN],
866
+ 'background-position': [CssProp.BACKGROUND_POSITION],
867
+ 'background-repeat': [CssProp.BACKGROUND_REPEAT],
868
+ 'background-size': [CssProp.BACKGROUND_SIZE],
869
+ border: [CssProp.BORDER],
870
+ 'border-bottom': [CssProp.BORDER_BOTTOM],
871
+ 'border-bottom-color': [CssProp.BORDER_BOTTOM_COLOR],
872
+ 'border-bottom-left-radius': [CssProp.BORDER_BOTTOM_LEFT_RADIUS],
873
+ 'border-bottom-right-radius': [CssProp.BORDER_BOTTOM_RIGHT_RADIUS],
874
+ 'border-bottom-style': [CssProp.BORDER_BOTTOM_STYLE],
875
+ 'border-bottom-width': [CssProp.BORDER_BOTTOM_WIDTH],
876
+ 'border-collapse': [CssProp.BORDER_COLLAPSE],
877
+ 'border-color': [CssProp.BORDER_COLOR],
878
+ 'border-left': [CssProp.BORDER_LEFT],
879
+ 'border-left-color': [CssProp.BORDER_LEFT_COLOR],
880
+ 'border-left-style': [CssProp.BORDER_LEFT_STYLE],
881
+ 'border-left-width': [CssProp.BORDER_LEFT_WIDTH],
882
+ 'border-radius': [CssProp.BORDER_RADIUS],
883
+ 'border-right': [CssProp.BORDER_RIGHT],
884
+ 'border-right-color': [CssProp.BORDER_RIGHT_COLOR],
885
+ 'border-right-style': [CssProp.BORDER_RIGHT_STYLE],
886
+ 'border-right-width': [CssProp.BORDER_RIGHT_WIDTH],
887
+ 'border-spacing': [CssProp.BORDER_SPACING],
888
+ 'border-style': [CssProp.BORDER_STYLE],
889
+ 'border-top': [CssProp.BORDER_TOP],
890
+ 'border-top-color': [CssProp.BORDER_TOP_COLOR],
891
+ 'border-top-left-radius': [CssProp.BORDER_TOP_LEFT_RADIUS],
892
+ 'border-top-right-radius': [CssProp.BORDER_TOP_RIGHT_RADIUS],
893
+ 'border-top-style': [CssProp.BORDER_TOP_STYLE],
894
+ 'border-top-width': [CssProp.BORDER_TOP_WIDTH],
895
+ 'border-width': [CssProp.BORDER_WIDTH],
896
+ bottom: [CssProp.BOTTOM],
897
+ box: [CssProp.BOX],
898
+ 'box-shadow': [CssProp.BOX_SHADOW],
899
+ 'box-sizing': [CssProp.BOX_SIZING],
900
+ 'caption-side': [CssProp.CAPTION_SIDE],
901
+ clear: [CssProp.CLEAR],
902
+ clip: [CssProp.CLIP],
903
+ color: [CssProp.COLOR],
904
+ cursor: [CssProp.CURSOR],
905
+ direction: [CssProp.DIRECTION],
906
+ display: [CssProp.DISPLAY],
907
+ 'display-inside': [CssProp.DISPLAY_INSIDE],
908
+ 'display-outside': [CssProp.DISPLAY_OUTSIDE],
909
+ elevation: [CssProp.ELEVATION],
910
+ 'empty-cells': [CssProp.EMPTY_CELLS],
911
+ float: [CssProp.FLOAT],
912
+ font: [CssProp.FONT],
913
+ 'font-family': [CssProp.FONT_FAMILY],
914
+ 'font-size': [CssProp.FONT_SIZE],
915
+ 'font-stretch': [CssProp.FONT_STRETCH],
916
+ 'font-style': [CssProp.FONT_STYLE],
917
+ 'font-variant': [CssProp.FONT_VARIANT],
918
+ 'font-weight': [CssProp.FONT_WEIGHT],
919
+ height: [CssProp.HEIGHT],
920
+ left: [CssProp.LEFT],
921
+ 'letter-spacing': [CssProp.LETTER_SPACING],
922
+ 'line-height': [CssProp.LINE_HEIGHT],
923
+ 'list-style': [CssProp.LIST_STYLE],
924
+ 'list-style-image': [CssProp.LIST_STYLE_IMAGE],
925
+ 'list-style-position': [CssProp.LIST_STYLE_POSITION],
926
+ 'list-style-type': [CssProp.LIST_STYLE_TYPE],
927
+ margin: [CssProp.MARGIN],
928
+ 'margin-bottom': [CssProp.MARGIN_BOTTOM],
929
+ 'margin-left': [CssProp.MARGIN_LEFT],
930
+ 'margin-right': [CssProp.MARGIN_RIGHT],
931
+ 'margin-top': [CssProp.MARGIN_TOP],
932
+ 'max-height': [CssProp.MAX_HEIGHT],
933
+ 'max-width': [CssProp.MAX_WIDTH],
934
+ 'min-height': [CssProp.MIN_HEIGHT],
935
+ 'min-width': [CssProp.MIN_WIDTH],
936
+ opacity: [CssProp.OPACITY],
937
+ outline: [CssProp.OUTLINE],
938
+ 'outline-color': [CssProp.OUTLINE_COLOR],
939
+ 'outline-style': [CssProp.OUTLINE_STYLE],
940
+ 'outline-width': [CssProp.OUTLINE_WIDTH],
941
+ overflow: [CssProp.OVERFLOW],
942
+ 'overflow-wrap': [CssProp.OVERFLOW_WRAP],
943
+ 'overflow-x': [CssProp.OVERFLOW_X],
944
+ 'overflow-y': [CssProp.OVERFLOW_Y],
945
+ padding: [CssProp.PADDING],
946
+ 'padding-bottom': [CssProp.PADDING_BOTTOM],
947
+ 'padding-left': [CssProp.PADDING_LEFT],
948
+ 'padding-right': [CssProp.PADDING_RIGHT],
949
+ 'padding-top': [CssProp.PADDING_TOP],
950
+ 'page-break-after': [CssProp.PAGE_BREAK_AFTER],
951
+ 'page-break-before': [CssProp.PAGE_BREAK_BEFORE],
952
+ 'page-break-inside': [CssProp.PAGE_BREAK_INSIDE],
953
+ 'pause-after': [CssProp.PAUSE_AFTER],
954
+ perspective: [CssProp.PERSPECTIVE],
955
+ pitch: [CssProp.PITCH],
956
+ 'pitch-range': [CssProp.PITCH_RANGE],
957
+ position: [CssProp.POSITION],
958
+ quotes: [CssProp.QUOTES],
959
+ resize: [CssProp.RESIZE],
960
+ richness: [CssProp.RICHNESS],
961
+ right: [CssProp.RIGHT],
962
+ speak: [CssProp.SPEAK],
963
+ 'speak-header': [CssProp.SPEAK_HEADER],
964
+ 'speak-numeral': [CssProp.SPEAK_NUMERAL],
965
+ 'speak-punctuation': [CssProp.SPEAK_PUNCTUATION],
966
+ 'speech-rate': [CssProp.SPEECH_RATE],
967
+ stress: [CssProp.STRESS],
968
+ 'table-layout': [CssProp.TABLE_LAYOUT],
969
+ 'text-align': [CssProp.TEXT_ALIGN],
970
+ 'text-decoration': [CssProp.TEXT_DECORATION],
971
+ 'text-indent': [CssProp.TEXT_INDENT],
972
+ 'text-overflow': [CssProp.TEXT_OVERFLOW],
973
+ 'text-shadow': [CssProp.TEXT_SHADOW],
974
+ 'text-transform': [CssProp.TEXT_TRANSFORM],
975
+ 'text-wrap': [CssProp.TEXT_WRAP],
976
+ top: [CssProp.TOP],
977
+ 'unicode-bidi': [CssProp.UNICODE_BIDI],
978
+ 'vertical-align': [CssProp.VERTICAL_ALIGN],
979
+ visibility: [CssProp.VISIBILITY],
980
+ volume: [CssProp.VOLUME],
981
+ 'white-space': [CssProp.WHITE_SPACE],
982
+ width: [CssProp.WIDTH],
983
+ 'word-break': [CssProp.WORD_BREAK],
984
+ 'word-spacing': [CssProp.WORD_SPACING],
985
+ 'word-wrap': [CssProp.WORD_WRAP],
986
+ 'z-index': [CssProp.Z_INDEX],
987
+ zoom: [CssProp.ZOOM]
988
+ }
989
+ },
990
+ transformTags: {
991
+ // Set the "rel" attribute for <a> tags to "nofollow".
992
+ a: sanitize.simpleTransform('a', { rel: 'nofollow' }),
993
+ // Set the "disabled" attribute for <input> tags.
994
+ input: sanitize.simpleTransform('input', { disabled: 'disabled' })
995
+ },
996
+ allowedSchemes: schemesToAllow,
997
+ allowedSchemesByTag: {
998
+ // Allow 'attachment:' img src (used for markdown cell attachments).
999
+ img: [...schemesToAllow, 'attachment']
1000
+ },
1001
+ // Override of the default option, so we can skip 'src' attribute validation.
1002
+ // 'src' Attributes are validated to be URIs, which does not allow for embedded (image) data.
1003
+ // Since embedded data is no longer deemed to be a threat, validation can be skipped.
1004
+ // See https://github.com/jupyterlab/jupyterlab/issues/5183
1005
+ allowedSchemesAppliedToAttributes: ['href', 'cite']
1006
+ };
1007
+ };
998
1008
  }