md-editor-v3 4.15.4 → 4.15.6
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/cjs/chunks/index.cjs +1365 -47
- package/lib/es/MdEditor.mjs +2 -2
- package/lib/es/chunks/event-name.mjs +13 -13
- package/lib/es/chunks/index.mjs +1356 -38
- package/lib/es/chunks/index4.mjs +3 -3
- package/lib/types/MdEditor/layouts/Content/markdownIt/xss/index.d.ts +14 -0
- package/lib/umd/index.js +37 -37
- package/package.json +3 -3
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { inject, onMounted, watch, toRef, nextTick, shallowRef, ref, computed, defineComponent, createVNode, Fragment, reactive, provide, onBeforeUnmount } from "vue";
|
|
2
2
|
import { p as prefix, f as configOption, g as codeCss, s as staticTextDefault, b as allToolbar, d as allFooter } from "./config.mjs";
|
|
3
|
-
import { b as bus, C as CATALOG_CHANGED, P as PUSH_CATALOG,
|
|
3
|
+
import { b as bus, C as CATALOG_CHANGED, P as PUSH_CATALOG, h as RERENDER, B as BUILD_FINISHED, d as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, c as CHANGE_CATALOG_VISIBLE, i as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, j as PREVIEW_CHANGED, k as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, l as CATALOG_VISIBLE_CHANGED, R as REPLACE, a as CHANGE_FULL_SCREEN, g as EVENT_LISTENER } from "./event-name.mjs";
|
|
4
4
|
import { a as appendHandler, u as updateHandler } from "./dom.mjs";
|
|
5
5
|
import { debounce, uuid, deepMerge, deepClone } from "@vavt/util";
|
|
6
6
|
import mediumZoom from "medium-zoom";
|
|
@@ -8,14 +8,32 @@ import copy from "copy-to-clipboard";
|
|
|
8
8
|
import mdit from "markdown-it";
|
|
9
9
|
import ImageFiguresPlugin from "markdown-it-image-figures";
|
|
10
10
|
import TaskListPlugin from "markdown-it-task-lists";
|
|
11
|
-
import
|
|
12
|
-
import { b as generateCodeRowNumber, c as getNextId } from "./index4.mjs";
|
|
11
|
+
import { c as generateCodeRowNumber, d as getNextId } from "./index4.mjs";
|
|
13
12
|
import { LRUCache } from "lru-cache";
|
|
13
|
+
function _mergeNamespaces(n, m) {
|
|
14
|
+
for (var i = 0; i < m.length; i++) {
|
|
15
|
+
const e = m[i];
|
|
16
|
+
if (typeof e !== "string" && !Array.isArray(e)) {
|
|
17
|
+
for (const k in e) {
|
|
18
|
+
if (k !== "default" && !(k in n)) {
|
|
19
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
if (d) {
|
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: () => e[k]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
|
|
31
|
+
}
|
|
14
32
|
const userZoom = (props, html) => {
|
|
15
33
|
const editorId = inject("editorId");
|
|
16
34
|
const { noImgZoomIn } = props;
|
|
17
35
|
const zoomHander = debounce(() => {
|
|
18
|
-
const imgs = document.querySelectorAll(`#${editorId}-preview img`);
|
|
36
|
+
const imgs = document.querySelectorAll(`#${editorId}-preview img:not(.not-zoom)`);
|
|
19
37
|
if (imgs.length === 0) {
|
|
20
38
|
return;
|
|
21
39
|
}
|
|
@@ -430,7 +448,7 @@ const AdmonitionPlugin = (md, options) => {
|
|
|
430
448
|
options = options || {};
|
|
431
449
|
const markers = 3, markerStr = options.marker || "!", markerChar = markerStr.charCodeAt(0), markerLen = markerStr.length;
|
|
432
450
|
let type = "", title = "";
|
|
433
|
-
const render = (tokens, idx, _options, _env,
|
|
451
|
+
const render = (tokens, idx, _options, _env, self2) => {
|
|
434
452
|
const token = tokens[idx];
|
|
435
453
|
if (token.type === "admonition_open") {
|
|
436
454
|
tokens[idx].attrPush([
|
|
@@ -440,7 +458,7 @@ const AdmonitionPlugin = (md, options) => {
|
|
|
440
458
|
} else if (token.type === "admonition_title_open") {
|
|
441
459
|
tokens[idx].attrPush(["class", `${prefix}-admonition-title`]);
|
|
442
460
|
}
|
|
443
|
-
return
|
|
461
|
+
return self2.renderToken(tokens, idx, _options);
|
|
444
462
|
};
|
|
445
463
|
const validate = (params) => {
|
|
446
464
|
const array = params.trim().split(" ", 2);
|
|
@@ -566,8 +584,8 @@ const HeadingPlugin = (md, options) => {
|
|
|
566
584
|
}
|
|
567
585
|
return md.renderer.renderToken(tokens, idx, options);
|
|
568
586
|
};
|
|
569
|
-
md.renderer.rules.heading_close = (tokens, idx, opts, _env,
|
|
570
|
-
return
|
|
587
|
+
md.renderer.rules.heading_close = (tokens, idx, opts, _env, self2) => {
|
|
588
|
+
return self2.renderToken(tokens, idx, opts);
|
|
571
589
|
};
|
|
572
590
|
};
|
|
573
591
|
const HeadingPlugin$1 = HeadingPlugin;
|
|
@@ -658,6 +676,1331 @@ const codetabs = (md, _opts) => {
|
|
|
658
676
|
md.renderer.rules.fence = fenceGroup;
|
|
659
677
|
};
|
|
660
678
|
const CodePlugin = codetabs;
|
|
679
|
+
function getDefaultExportFromCjs(x) {
|
|
680
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
681
|
+
}
|
|
682
|
+
var lib$1 = { exports: {} };
|
|
683
|
+
var _default$1 = {};
|
|
684
|
+
var lib = { exports: {} };
|
|
685
|
+
var _default = {};
|
|
686
|
+
function getDefaultWhiteList$1() {
|
|
687
|
+
var whiteList = {};
|
|
688
|
+
whiteList["align-content"] = false;
|
|
689
|
+
whiteList["align-items"] = false;
|
|
690
|
+
whiteList["align-self"] = false;
|
|
691
|
+
whiteList["alignment-adjust"] = false;
|
|
692
|
+
whiteList["alignment-baseline"] = false;
|
|
693
|
+
whiteList["all"] = false;
|
|
694
|
+
whiteList["anchor-point"] = false;
|
|
695
|
+
whiteList["animation"] = false;
|
|
696
|
+
whiteList["animation-delay"] = false;
|
|
697
|
+
whiteList["animation-direction"] = false;
|
|
698
|
+
whiteList["animation-duration"] = false;
|
|
699
|
+
whiteList["animation-fill-mode"] = false;
|
|
700
|
+
whiteList["animation-iteration-count"] = false;
|
|
701
|
+
whiteList["animation-name"] = false;
|
|
702
|
+
whiteList["animation-play-state"] = false;
|
|
703
|
+
whiteList["animation-timing-function"] = false;
|
|
704
|
+
whiteList["azimuth"] = false;
|
|
705
|
+
whiteList["backface-visibility"] = false;
|
|
706
|
+
whiteList["background"] = true;
|
|
707
|
+
whiteList["background-attachment"] = true;
|
|
708
|
+
whiteList["background-clip"] = true;
|
|
709
|
+
whiteList["background-color"] = true;
|
|
710
|
+
whiteList["background-image"] = true;
|
|
711
|
+
whiteList["background-origin"] = true;
|
|
712
|
+
whiteList["background-position"] = true;
|
|
713
|
+
whiteList["background-repeat"] = true;
|
|
714
|
+
whiteList["background-size"] = true;
|
|
715
|
+
whiteList["baseline-shift"] = false;
|
|
716
|
+
whiteList["binding"] = false;
|
|
717
|
+
whiteList["bleed"] = false;
|
|
718
|
+
whiteList["bookmark-label"] = false;
|
|
719
|
+
whiteList["bookmark-level"] = false;
|
|
720
|
+
whiteList["bookmark-state"] = false;
|
|
721
|
+
whiteList["border"] = true;
|
|
722
|
+
whiteList["border-bottom"] = true;
|
|
723
|
+
whiteList["border-bottom-color"] = true;
|
|
724
|
+
whiteList["border-bottom-left-radius"] = true;
|
|
725
|
+
whiteList["border-bottom-right-radius"] = true;
|
|
726
|
+
whiteList["border-bottom-style"] = true;
|
|
727
|
+
whiteList["border-bottom-width"] = true;
|
|
728
|
+
whiteList["border-collapse"] = true;
|
|
729
|
+
whiteList["border-color"] = true;
|
|
730
|
+
whiteList["border-image"] = true;
|
|
731
|
+
whiteList["border-image-outset"] = true;
|
|
732
|
+
whiteList["border-image-repeat"] = true;
|
|
733
|
+
whiteList["border-image-slice"] = true;
|
|
734
|
+
whiteList["border-image-source"] = true;
|
|
735
|
+
whiteList["border-image-width"] = true;
|
|
736
|
+
whiteList["border-left"] = true;
|
|
737
|
+
whiteList["border-left-color"] = true;
|
|
738
|
+
whiteList["border-left-style"] = true;
|
|
739
|
+
whiteList["border-left-width"] = true;
|
|
740
|
+
whiteList["border-radius"] = true;
|
|
741
|
+
whiteList["border-right"] = true;
|
|
742
|
+
whiteList["border-right-color"] = true;
|
|
743
|
+
whiteList["border-right-style"] = true;
|
|
744
|
+
whiteList["border-right-width"] = true;
|
|
745
|
+
whiteList["border-spacing"] = true;
|
|
746
|
+
whiteList["border-style"] = true;
|
|
747
|
+
whiteList["border-top"] = true;
|
|
748
|
+
whiteList["border-top-color"] = true;
|
|
749
|
+
whiteList["border-top-left-radius"] = true;
|
|
750
|
+
whiteList["border-top-right-radius"] = true;
|
|
751
|
+
whiteList["border-top-style"] = true;
|
|
752
|
+
whiteList["border-top-width"] = true;
|
|
753
|
+
whiteList["border-width"] = true;
|
|
754
|
+
whiteList["bottom"] = false;
|
|
755
|
+
whiteList["box-decoration-break"] = true;
|
|
756
|
+
whiteList["box-shadow"] = true;
|
|
757
|
+
whiteList["box-sizing"] = true;
|
|
758
|
+
whiteList["box-snap"] = true;
|
|
759
|
+
whiteList["box-suppress"] = true;
|
|
760
|
+
whiteList["break-after"] = true;
|
|
761
|
+
whiteList["break-before"] = true;
|
|
762
|
+
whiteList["break-inside"] = true;
|
|
763
|
+
whiteList["caption-side"] = false;
|
|
764
|
+
whiteList["chains"] = false;
|
|
765
|
+
whiteList["clear"] = true;
|
|
766
|
+
whiteList["clip"] = false;
|
|
767
|
+
whiteList["clip-path"] = false;
|
|
768
|
+
whiteList["clip-rule"] = false;
|
|
769
|
+
whiteList["color"] = true;
|
|
770
|
+
whiteList["color-interpolation-filters"] = true;
|
|
771
|
+
whiteList["column-count"] = false;
|
|
772
|
+
whiteList["column-fill"] = false;
|
|
773
|
+
whiteList["column-gap"] = false;
|
|
774
|
+
whiteList["column-rule"] = false;
|
|
775
|
+
whiteList["column-rule-color"] = false;
|
|
776
|
+
whiteList["column-rule-style"] = false;
|
|
777
|
+
whiteList["column-rule-width"] = false;
|
|
778
|
+
whiteList["column-span"] = false;
|
|
779
|
+
whiteList["column-width"] = false;
|
|
780
|
+
whiteList["columns"] = false;
|
|
781
|
+
whiteList["contain"] = false;
|
|
782
|
+
whiteList["content"] = false;
|
|
783
|
+
whiteList["counter-increment"] = false;
|
|
784
|
+
whiteList["counter-reset"] = false;
|
|
785
|
+
whiteList["counter-set"] = false;
|
|
786
|
+
whiteList["crop"] = false;
|
|
787
|
+
whiteList["cue"] = false;
|
|
788
|
+
whiteList["cue-after"] = false;
|
|
789
|
+
whiteList["cue-before"] = false;
|
|
790
|
+
whiteList["cursor"] = false;
|
|
791
|
+
whiteList["direction"] = false;
|
|
792
|
+
whiteList["display"] = true;
|
|
793
|
+
whiteList["display-inside"] = true;
|
|
794
|
+
whiteList["display-list"] = true;
|
|
795
|
+
whiteList["display-outside"] = true;
|
|
796
|
+
whiteList["dominant-baseline"] = false;
|
|
797
|
+
whiteList["elevation"] = false;
|
|
798
|
+
whiteList["empty-cells"] = false;
|
|
799
|
+
whiteList["filter"] = false;
|
|
800
|
+
whiteList["flex"] = false;
|
|
801
|
+
whiteList["flex-basis"] = false;
|
|
802
|
+
whiteList["flex-direction"] = false;
|
|
803
|
+
whiteList["flex-flow"] = false;
|
|
804
|
+
whiteList["flex-grow"] = false;
|
|
805
|
+
whiteList["flex-shrink"] = false;
|
|
806
|
+
whiteList["flex-wrap"] = false;
|
|
807
|
+
whiteList["float"] = false;
|
|
808
|
+
whiteList["float-offset"] = false;
|
|
809
|
+
whiteList["flood-color"] = false;
|
|
810
|
+
whiteList["flood-opacity"] = false;
|
|
811
|
+
whiteList["flow-from"] = false;
|
|
812
|
+
whiteList["flow-into"] = false;
|
|
813
|
+
whiteList["font"] = true;
|
|
814
|
+
whiteList["font-family"] = true;
|
|
815
|
+
whiteList["font-feature-settings"] = true;
|
|
816
|
+
whiteList["font-kerning"] = true;
|
|
817
|
+
whiteList["font-language-override"] = true;
|
|
818
|
+
whiteList["font-size"] = true;
|
|
819
|
+
whiteList["font-size-adjust"] = true;
|
|
820
|
+
whiteList["font-stretch"] = true;
|
|
821
|
+
whiteList["font-style"] = true;
|
|
822
|
+
whiteList["font-synthesis"] = true;
|
|
823
|
+
whiteList["font-variant"] = true;
|
|
824
|
+
whiteList["font-variant-alternates"] = true;
|
|
825
|
+
whiteList["font-variant-caps"] = true;
|
|
826
|
+
whiteList["font-variant-east-asian"] = true;
|
|
827
|
+
whiteList["font-variant-ligatures"] = true;
|
|
828
|
+
whiteList["font-variant-numeric"] = true;
|
|
829
|
+
whiteList["font-variant-position"] = true;
|
|
830
|
+
whiteList["font-weight"] = true;
|
|
831
|
+
whiteList["grid"] = false;
|
|
832
|
+
whiteList["grid-area"] = false;
|
|
833
|
+
whiteList["grid-auto-columns"] = false;
|
|
834
|
+
whiteList["grid-auto-flow"] = false;
|
|
835
|
+
whiteList["grid-auto-rows"] = false;
|
|
836
|
+
whiteList["grid-column"] = false;
|
|
837
|
+
whiteList["grid-column-end"] = false;
|
|
838
|
+
whiteList["grid-column-start"] = false;
|
|
839
|
+
whiteList["grid-row"] = false;
|
|
840
|
+
whiteList["grid-row-end"] = false;
|
|
841
|
+
whiteList["grid-row-start"] = false;
|
|
842
|
+
whiteList["grid-template"] = false;
|
|
843
|
+
whiteList["grid-template-areas"] = false;
|
|
844
|
+
whiteList["grid-template-columns"] = false;
|
|
845
|
+
whiteList["grid-template-rows"] = false;
|
|
846
|
+
whiteList["hanging-punctuation"] = false;
|
|
847
|
+
whiteList["height"] = true;
|
|
848
|
+
whiteList["hyphens"] = false;
|
|
849
|
+
whiteList["icon"] = false;
|
|
850
|
+
whiteList["image-orientation"] = false;
|
|
851
|
+
whiteList["image-resolution"] = false;
|
|
852
|
+
whiteList["ime-mode"] = false;
|
|
853
|
+
whiteList["initial-letters"] = false;
|
|
854
|
+
whiteList["inline-box-align"] = false;
|
|
855
|
+
whiteList["justify-content"] = false;
|
|
856
|
+
whiteList["justify-items"] = false;
|
|
857
|
+
whiteList["justify-self"] = false;
|
|
858
|
+
whiteList["left"] = false;
|
|
859
|
+
whiteList["letter-spacing"] = true;
|
|
860
|
+
whiteList["lighting-color"] = true;
|
|
861
|
+
whiteList["line-box-contain"] = false;
|
|
862
|
+
whiteList["line-break"] = false;
|
|
863
|
+
whiteList["line-grid"] = false;
|
|
864
|
+
whiteList["line-height"] = false;
|
|
865
|
+
whiteList["line-snap"] = false;
|
|
866
|
+
whiteList["line-stacking"] = false;
|
|
867
|
+
whiteList["line-stacking-ruby"] = false;
|
|
868
|
+
whiteList["line-stacking-shift"] = false;
|
|
869
|
+
whiteList["line-stacking-strategy"] = false;
|
|
870
|
+
whiteList["list-style"] = true;
|
|
871
|
+
whiteList["list-style-image"] = true;
|
|
872
|
+
whiteList["list-style-position"] = true;
|
|
873
|
+
whiteList["list-style-type"] = true;
|
|
874
|
+
whiteList["margin"] = true;
|
|
875
|
+
whiteList["margin-bottom"] = true;
|
|
876
|
+
whiteList["margin-left"] = true;
|
|
877
|
+
whiteList["margin-right"] = true;
|
|
878
|
+
whiteList["margin-top"] = true;
|
|
879
|
+
whiteList["marker-offset"] = false;
|
|
880
|
+
whiteList["marker-side"] = false;
|
|
881
|
+
whiteList["marks"] = false;
|
|
882
|
+
whiteList["mask"] = false;
|
|
883
|
+
whiteList["mask-box"] = false;
|
|
884
|
+
whiteList["mask-box-outset"] = false;
|
|
885
|
+
whiteList["mask-box-repeat"] = false;
|
|
886
|
+
whiteList["mask-box-slice"] = false;
|
|
887
|
+
whiteList["mask-box-source"] = false;
|
|
888
|
+
whiteList["mask-box-width"] = false;
|
|
889
|
+
whiteList["mask-clip"] = false;
|
|
890
|
+
whiteList["mask-image"] = false;
|
|
891
|
+
whiteList["mask-origin"] = false;
|
|
892
|
+
whiteList["mask-position"] = false;
|
|
893
|
+
whiteList["mask-repeat"] = false;
|
|
894
|
+
whiteList["mask-size"] = false;
|
|
895
|
+
whiteList["mask-source-type"] = false;
|
|
896
|
+
whiteList["mask-type"] = false;
|
|
897
|
+
whiteList["max-height"] = true;
|
|
898
|
+
whiteList["max-lines"] = false;
|
|
899
|
+
whiteList["max-width"] = true;
|
|
900
|
+
whiteList["min-height"] = true;
|
|
901
|
+
whiteList["min-width"] = true;
|
|
902
|
+
whiteList["move-to"] = false;
|
|
903
|
+
whiteList["nav-down"] = false;
|
|
904
|
+
whiteList["nav-index"] = false;
|
|
905
|
+
whiteList["nav-left"] = false;
|
|
906
|
+
whiteList["nav-right"] = false;
|
|
907
|
+
whiteList["nav-up"] = false;
|
|
908
|
+
whiteList["object-fit"] = false;
|
|
909
|
+
whiteList["object-position"] = false;
|
|
910
|
+
whiteList["opacity"] = false;
|
|
911
|
+
whiteList["order"] = false;
|
|
912
|
+
whiteList["orphans"] = false;
|
|
913
|
+
whiteList["outline"] = false;
|
|
914
|
+
whiteList["outline-color"] = false;
|
|
915
|
+
whiteList["outline-offset"] = false;
|
|
916
|
+
whiteList["outline-style"] = false;
|
|
917
|
+
whiteList["outline-width"] = false;
|
|
918
|
+
whiteList["overflow"] = false;
|
|
919
|
+
whiteList["overflow-wrap"] = false;
|
|
920
|
+
whiteList["overflow-x"] = false;
|
|
921
|
+
whiteList["overflow-y"] = false;
|
|
922
|
+
whiteList["padding"] = true;
|
|
923
|
+
whiteList["padding-bottom"] = true;
|
|
924
|
+
whiteList["padding-left"] = true;
|
|
925
|
+
whiteList["padding-right"] = true;
|
|
926
|
+
whiteList["padding-top"] = true;
|
|
927
|
+
whiteList["page"] = false;
|
|
928
|
+
whiteList["page-break-after"] = false;
|
|
929
|
+
whiteList["page-break-before"] = false;
|
|
930
|
+
whiteList["page-break-inside"] = false;
|
|
931
|
+
whiteList["page-policy"] = false;
|
|
932
|
+
whiteList["pause"] = false;
|
|
933
|
+
whiteList["pause-after"] = false;
|
|
934
|
+
whiteList["pause-before"] = false;
|
|
935
|
+
whiteList["perspective"] = false;
|
|
936
|
+
whiteList["perspective-origin"] = false;
|
|
937
|
+
whiteList["pitch"] = false;
|
|
938
|
+
whiteList["pitch-range"] = false;
|
|
939
|
+
whiteList["play-during"] = false;
|
|
940
|
+
whiteList["position"] = false;
|
|
941
|
+
whiteList["presentation-level"] = false;
|
|
942
|
+
whiteList["quotes"] = false;
|
|
943
|
+
whiteList["region-fragment"] = false;
|
|
944
|
+
whiteList["resize"] = false;
|
|
945
|
+
whiteList["rest"] = false;
|
|
946
|
+
whiteList["rest-after"] = false;
|
|
947
|
+
whiteList["rest-before"] = false;
|
|
948
|
+
whiteList["richness"] = false;
|
|
949
|
+
whiteList["right"] = false;
|
|
950
|
+
whiteList["rotation"] = false;
|
|
951
|
+
whiteList["rotation-point"] = false;
|
|
952
|
+
whiteList["ruby-align"] = false;
|
|
953
|
+
whiteList["ruby-merge"] = false;
|
|
954
|
+
whiteList["ruby-position"] = false;
|
|
955
|
+
whiteList["shape-image-threshold"] = false;
|
|
956
|
+
whiteList["shape-outside"] = false;
|
|
957
|
+
whiteList["shape-margin"] = false;
|
|
958
|
+
whiteList["size"] = false;
|
|
959
|
+
whiteList["speak"] = false;
|
|
960
|
+
whiteList["speak-as"] = false;
|
|
961
|
+
whiteList["speak-header"] = false;
|
|
962
|
+
whiteList["speak-numeral"] = false;
|
|
963
|
+
whiteList["speak-punctuation"] = false;
|
|
964
|
+
whiteList["speech-rate"] = false;
|
|
965
|
+
whiteList["stress"] = false;
|
|
966
|
+
whiteList["string-set"] = false;
|
|
967
|
+
whiteList["tab-size"] = false;
|
|
968
|
+
whiteList["table-layout"] = false;
|
|
969
|
+
whiteList["text-align"] = true;
|
|
970
|
+
whiteList["text-align-last"] = true;
|
|
971
|
+
whiteList["text-combine-upright"] = true;
|
|
972
|
+
whiteList["text-decoration"] = true;
|
|
973
|
+
whiteList["text-decoration-color"] = true;
|
|
974
|
+
whiteList["text-decoration-line"] = true;
|
|
975
|
+
whiteList["text-decoration-skip"] = true;
|
|
976
|
+
whiteList["text-decoration-style"] = true;
|
|
977
|
+
whiteList["text-emphasis"] = true;
|
|
978
|
+
whiteList["text-emphasis-color"] = true;
|
|
979
|
+
whiteList["text-emphasis-position"] = true;
|
|
980
|
+
whiteList["text-emphasis-style"] = true;
|
|
981
|
+
whiteList["text-height"] = true;
|
|
982
|
+
whiteList["text-indent"] = true;
|
|
983
|
+
whiteList["text-justify"] = true;
|
|
984
|
+
whiteList["text-orientation"] = true;
|
|
985
|
+
whiteList["text-overflow"] = true;
|
|
986
|
+
whiteList["text-shadow"] = true;
|
|
987
|
+
whiteList["text-space-collapse"] = true;
|
|
988
|
+
whiteList["text-transform"] = true;
|
|
989
|
+
whiteList["text-underline-position"] = true;
|
|
990
|
+
whiteList["text-wrap"] = true;
|
|
991
|
+
whiteList["top"] = false;
|
|
992
|
+
whiteList["transform"] = false;
|
|
993
|
+
whiteList["transform-origin"] = false;
|
|
994
|
+
whiteList["transform-style"] = false;
|
|
995
|
+
whiteList["transition"] = false;
|
|
996
|
+
whiteList["transition-delay"] = false;
|
|
997
|
+
whiteList["transition-duration"] = false;
|
|
998
|
+
whiteList["transition-property"] = false;
|
|
999
|
+
whiteList["transition-timing-function"] = false;
|
|
1000
|
+
whiteList["unicode-bidi"] = false;
|
|
1001
|
+
whiteList["vertical-align"] = false;
|
|
1002
|
+
whiteList["visibility"] = false;
|
|
1003
|
+
whiteList["voice-balance"] = false;
|
|
1004
|
+
whiteList["voice-duration"] = false;
|
|
1005
|
+
whiteList["voice-family"] = false;
|
|
1006
|
+
whiteList["voice-pitch"] = false;
|
|
1007
|
+
whiteList["voice-range"] = false;
|
|
1008
|
+
whiteList["voice-rate"] = false;
|
|
1009
|
+
whiteList["voice-stress"] = false;
|
|
1010
|
+
whiteList["voice-volume"] = false;
|
|
1011
|
+
whiteList["volume"] = false;
|
|
1012
|
+
whiteList["white-space"] = false;
|
|
1013
|
+
whiteList["widows"] = false;
|
|
1014
|
+
whiteList["width"] = true;
|
|
1015
|
+
whiteList["will-change"] = false;
|
|
1016
|
+
whiteList["word-break"] = true;
|
|
1017
|
+
whiteList["word-spacing"] = true;
|
|
1018
|
+
whiteList["word-wrap"] = true;
|
|
1019
|
+
whiteList["wrap-flow"] = false;
|
|
1020
|
+
whiteList["wrap-through"] = false;
|
|
1021
|
+
whiteList["writing-mode"] = false;
|
|
1022
|
+
whiteList["z-index"] = false;
|
|
1023
|
+
return whiteList;
|
|
1024
|
+
}
|
|
1025
|
+
function onAttr(name, value, options) {
|
|
1026
|
+
}
|
|
1027
|
+
function onIgnoreAttr(name, value, options) {
|
|
1028
|
+
}
|
|
1029
|
+
var REGEXP_URL_JAVASCRIPT = /javascript\s*\:/img;
|
|
1030
|
+
function safeAttrValue$1(name, value) {
|
|
1031
|
+
if (REGEXP_URL_JAVASCRIPT.test(value))
|
|
1032
|
+
return "";
|
|
1033
|
+
return value;
|
|
1034
|
+
}
|
|
1035
|
+
_default.whiteList = getDefaultWhiteList$1();
|
|
1036
|
+
_default.getDefaultWhiteList = getDefaultWhiteList$1;
|
|
1037
|
+
_default.onAttr = onAttr;
|
|
1038
|
+
_default.onIgnoreAttr = onIgnoreAttr;
|
|
1039
|
+
_default.safeAttrValue = safeAttrValue$1;
|
|
1040
|
+
var util$1 = {
|
|
1041
|
+
indexOf: function(arr, item) {
|
|
1042
|
+
var i, j;
|
|
1043
|
+
if (Array.prototype.indexOf) {
|
|
1044
|
+
return arr.indexOf(item);
|
|
1045
|
+
}
|
|
1046
|
+
for (i = 0, j = arr.length; i < j; i++) {
|
|
1047
|
+
if (arr[i] === item) {
|
|
1048
|
+
return i;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
return -1;
|
|
1052
|
+
},
|
|
1053
|
+
forEach: function(arr, fn, scope) {
|
|
1054
|
+
var i, j;
|
|
1055
|
+
if (Array.prototype.forEach) {
|
|
1056
|
+
return arr.forEach(fn, scope);
|
|
1057
|
+
}
|
|
1058
|
+
for (i = 0, j = arr.length; i < j; i++) {
|
|
1059
|
+
fn.call(scope, arr[i], i, arr);
|
|
1060
|
+
}
|
|
1061
|
+
},
|
|
1062
|
+
trim: function(str) {
|
|
1063
|
+
if (String.prototype.trim) {
|
|
1064
|
+
return str.trim();
|
|
1065
|
+
}
|
|
1066
|
+
return str.replace(/(^\s*)|(\s*$)/g, "");
|
|
1067
|
+
},
|
|
1068
|
+
trimRight: function(str) {
|
|
1069
|
+
if (String.prototype.trimRight) {
|
|
1070
|
+
return str.trimRight();
|
|
1071
|
+
}
|
|
1072
|
+
return str.replace(/(\s*$)/g, "");
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
var _$3 = util$1;
|
|
1076
|
+
function parseStyle$1(css2, onAttr2) {
|
|
1077
|
+
css2 = _$3.trimRight(css2);
|
|
1078
|
+
if (css2[css2.length - 1] !== ";")
|
|
1079
|
+
css2 += ";";
|
|
1080
|
+
var cssLength = css2.length;
|
|
1081
|
+
var isParenthesisOpen = false;
|
|
1082
|
+
var lastPos = 0;
|
|
1083
|
+
var i = 0;
|
|
1084
|
+
var retCSS = "";
|
|
1085
|
+
function addNewAttr() {
|
|
1086
|
+
if (!isParenthesisOpen) {
|
|
1087
|
+
var source = _$3.trim(css2.slice(lastPos, i));
|
|
1088
|
+
var j2 = source.indexOf(":");
|
|
1089
|
+
if (j2 !== -1) {
|
|
1090
|
+
var name = _$3.trim(source.slice(0, j2));
|
|
1091
|
+
var value = _$3.trim(source.slice(j2 + 1));
|
|
1092
|
+
if (name) {
|
|
1093
|
+
var ret = onAttr2(lastPos, retCSS.length, name, value, source);
|
|
1094
|
+
if (ret)
|
|
1095
|
+
retCSS += ret + "; ";
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
lastPos = i + 1;
|
|
1100
|
+
}
|
|
1101
|
+
for (; i < cssLength; i++) {
|
|
1102
|
+
var c = css2[i];
|
|
1103
|
+
if (c === "/" && css2[i + 1] === "*") {
|
|
1104
|
+
var j = css2.indexOf("*/", i + 2);
|
|
1105
|
+
if (j === -1)
|
|
1106
|
+
break;
|
|
1107
|
+
i = j + 1;
|
|
1108
|
+
lastPos = i + 1;
|
|
1109
|
+
isParenthesisOpen = false;
|
|
1110
|
+
} else if (c === "(") {
|
|
1111
|
+
isParenthesisOpen = true;
|
|
1112
|
+
} else if (c === ")") {
|
|
1113
|
+
isParenthesisOpen = false;
|
|
1114
|
+
} else if (c === ";") {
|
|
1115
|
+
if (isParenthesisOpen)
|
|
1116
|
+
;
|
|
1117
|
+
else {
|
|
1118
|
+
addNewAttr();
|
|
1119
|
+
}
|
|
1120
|
+
} else if (c === "\n") {
|
|
1121
|
+
addNewAttr();
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return _$3.trim(retCSS);
|
|
1125
|
+
}
|
|
1126
|
+
var parser$2 = parseStyle$1;
|
|
1127
|
+
var DEFAULT$1 = _default;
|
|
1128
|
+
var parseStyle = parser$2;
|
|
1129
|
+
function isNull$1(obj) {
|
|
1130
|
+
return obj === void 0 || obj === null;
|
|
1131
|
+
}
|
|
1132
|
+
function shallowCopyObject$1(obj) {
|
|
1133
|
+
var ret = {};
|
|
1134
|
+
for (var i in obj) {
|
|
1135
|
+
ret[i] = obj[i];
|
|
1136
|
+
}
|
|
1137
|
+
return ret;
|
|
1138
|
+
}
|
|
1139
|
+
function FilterCSS$2(options) {
|
|
1140
|
+
options = shallowCopyObject$1(options || {});
|
|
1141
|
+
options.whiteList = options.whiteList || DEFAULT$1.whiteList;
|
|
1142
|
+
options.onAttr = options.onAttr || DEFAULT$1.onAttr;
|
|
1143
|
+
options.onIgnoreAttr = options.onIgnoreAttr || DEFAULT$1.onIgnoreAttr;
|
|
1144
|
+
options.safeAttrValue = options.safeAttrValue || DEFAULT$1.safeAttrValue;
|
|
1145
|
+
this.options = options;
|
|
1146
|
+
}
|
|
1147
|
+
FilterCSS$2.prototype.process = function(css2) {
|
|
1148
|
+
css2 = css2 || "";
|
|
1149
|
+
css2 = css2.toString();
|
|
1150
|
+
if (!css2)
|
|
1151
|
+
return "";
|
|
1152
|
+
var me = this;
|
|
1153
|
+
var options = me.options;
|
|
1154
|
+
var whiteList = options.whiteList;
|
|
1155
|
+
var onAttr2 = options.onAttr;
|
|
1156
|
+
var onIgnoreAttr2 = options.onIgnoreAttr;
|
|
1157
|
+
var safeAttrValue2 = options.safeAttrValue;
|
|
1158
|
+
var retCSS = parseStyle(css2, function(sourcePosition, position, name, value, source) {
|
|
1159
|
+
var check = whiteList[name];
|
|
1160
|
+
var isWhite = false;
|
|
1161
|
+
if (check === true)
|
|
1162
|
+
isWhite = check;
|
|
1163
|
+
else if (typeof check === "function")
|
|
1164
|
+
isWhite = check(value);
|
|
1165
|
+
else if (check instanceof RegExp)
|
|
1166
|
+
isWhite = check.test(value);
|
|
1167
|
+
if (isWhite !== true)
|
|
1168
|
+
isWhite = false;
|
|
1169
|
+
value = safeAttrValue2(name, value);
|
|
1170
|
+
if (!value)
|
|
1171
|
+
return;
|
|
1172
|
+
var opts = {
|
|
1173
|
+
position,
|
|
1174
|
+
sourcePosition,
|
|
1175
|
+
source,
|
|
1176
|
+
isWhite
|
|
1177
|
+
};
|
|
1178
|
+
if (isWhite) {
|
|
1179
|
+
var ret = onAttr2(name, value, opts);
|
|
1180
|
+
if (isNull$1(ret)) {
|
|
1181
|
+
return name + ":" + value;
|
|
1182
|
+
} else {
|
|
1183
|
+
return ret;
|
|
1184
|
+
}
|
|
1185
|
+
} else {
|
|
1186
|
+
var ret = onIgnoreAttr2(name, value, opts);
|
|
1187
|
+
if (!isNull$1(ret)) {
|
|
1188
|
+
return ret;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
return retCSS;
|
|
1193
|
+
};
|
|
1194
|
+
var css = FilterCSS$2;
|
|
1195
|
+
(function(module, exports) {
|
|
1196
|
+
var DEFAULT2 = _default;
|
|
1197
|
+
var FilterCSS2 = css;
|
|
1198
|
+
function filterCSS(html, options) {
|
|
1199
|
+
var xss2 = new FilterCSS2(options);
|
|
1200
|
+
return xss2.process(html);
|
|
1201
|
+
}
|
|
1202
|
+
exports = module.exports = filterCSS;
|
|
1203
|
+
exports.FilterCSS = FilterCSS2;
|
|
1204
|
+
for (var i in DEFAULT2)
|
|
1205
|
+
exports[i] = DEFAULT2[i];
|
|
1206
|
+
if (typeof window !== "undefined") {
|
|
1207
|
+
window.filterCSS = module.exports;
|
|
1208
|
+
}
|
|
1209
|
+
})(lib, lib.exports);
|
|
1210
|
+
var libExports$1 = lib.exports;
|
|
1211
|
+
var util = {
|
|
1212
|
+
indexOf: function(arr, item) {
|
|
1213
|
+
var i, j;
|
|
1214
|
+
if (Array.prototype.indexOf) {
|
|
1215
|
+
return arr.indexOf(item);
|
|
1216
|
+
}
|
|
1217
|
+
for (i = 0, j = arr.length; i < j; i++) {
|
|
1218
|
+
if (arr[i] === item) {
|
|
1219
|
+
return i;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
return -1;
|
|
1223
|
+
},
|
|
1224
|
+
forEach: function(arr, fn, scope) {
|
|
1225
|
+
var i, j;
|
|
1226
|
+
if (Array.prototype.forEach) {
|
|
1227
|
+
return arr.forEach(fn, scope);
|
|
1228
|
+
}
|
|
1229
|
+
for (i = 0, j = arr.length; i < j; i++) {
|
|
1230
|
+
fn.call(scope, arr[i], i, arr);
|
|
1231
|
+
}
|
|
1232
|
+
},
|
|
1233
|
+
trim: function(str) {
|
|
1234
|
+
if (String.prototype.trim) {
|
|
1235
|
+
return str.trim();
|
|
1236
|
+
}
|
|
1237
|
+
return str.replace(/(^\s*)|(\s*$)/g, "");
|
|
1238
|
+
},
|
|
1239
|
+
spaceIndex: function(str) {
|
|
1240
|
+
var reg = /\s|\n|\t/;
|
|
1241
|
+
var match = reg.exec(str);
|
|
1242
|
+
return match ? match.index : -1;
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
var FilterCSS$1 = libExports$1.FilterCSS;
|
|
1246
|
+
var getDefaultCSSWhiteList = libExports$1.getDefaultWhiteList;
|
|
1247
|
+
var _$2 = util;
|
|
1248
|
+
function getDefaultWhiteList() {
|
|
1249
|
+
return {
|
|
1250
|
+
a: ["target", "href", "title"],
|
|
1251
|
+
abbr: ["title"],
|
|
1252
|
+
address: [],
|
|
1253
|
+
area: ["shape", "coords", "href", "alt"],
|
|
1254
|
+
article: [],
|
|
1255
|
+
aside: [],
|
|
1256
|
+
audio: [
|
|
1257
|
+
"autoplay",
|
|
1258
|
+
"controls",
|
|
1259
|
+
"crossorigin",
|
|
1260
|
+
"loop",
|
|
1261
|
+
"muted",
|
|
1262
|
+
"preload",
|
|
1263
|
+
"src"
|
|
1264
|
+
],
|
|
1265
|
+
b: [],
|
|
1266
|
+
bdi: ["dir"],
|
|
1267
|
+
bdo: ["dir"],
|
|
1268
|
+
big: [],
|
|
1269
|
+
blockquote: ["cite"],
|
|
1270
|
+
br: [],
|
|
1271
|
+
caption: [],
|
|
1272
|
+
center: [],
|
|
1273
|
+
cite: [],
|
|
1274
|
+
code: [],
|
|
1275
|
+
col: ["align", "valign", "span", "width"],
|
|
1276
|
+
colgroup: ["align", "valign", "span", "width"],
|
|
1277
|
+
dd: [],
|
|
1278
|
+
del: ["datetime"],
|
|
1279
|
+
details: ["open"],
|
|
1280
|
+
div: [],
|
|
1281
|
+
dl: [],
|
|
1282
|
+
dt: [],
|
|
1283
|
+
em: [],
|
|
1284
|
+
figcaption: [],
|
|
1285
|
+
figure: [],
|
|
1286
|
+
font: ["color", "size", "face"],
|
|
1287
|
+
footer: [],
|
|
1288
|
+
h1: [],
|
|
1289
|
+
h2: [],
|
|
1290
|
+
h3: [],
|
|
1291
|
+
h4: [],
|
|
1292
|
+
h5: [],
|
|
1293
|
+
h6: [],
|
|
1294
|
+
header: [],
|
|
1295
|
+
hr: [],
|
|
1296
|
+
i: [],
|
|
1297
|
+
img: ["src", "alt", "title", "width", "height", "loading"],
|
|
1298
|
+
ins: ["datetime"],
|
|
1299
|
+
kbd: [],
|
|
1300
|
+
li: [],
|
|
1301
|
+
mark: [],
|
|
1302
|
+
nav: [],
|
|
1303
|
+
ol: [],
|
|
1304
|
+
p: [],
|
|
1305
|
+
pre: [],
|
|
1306
|
+
s: [],
|
|
1307
|
+
section: [],
|
|
1308
|
+
small: [],
|
|
1309
|
+
span: [],
|
|
1310
|
+
sub: [],
|
|
1311
|
+
summary: [],
|
|
1312
|
+
sup: [],
|
|
1313
|
+
strong: [],
|
|
1314
|
+
strike: [],
|
|
1315
|
+
table: ["width", "border", "align", "valign"],
|
|
1316
|
+
tbody: ["align", "valign"],
|
|
1317
|
+
td: ["width", "rowspan", "colspan", "align", "valign"],
|
|
1318
|
+
tfoot: ["align", "valign"],
|
|
1319
|
+
th: ["width", "rowspan", "colspan", "align", "valign"],
|
|
1320
|
+
thead: ["align", "valign"],
|
|
1321
|
+
tr: ["rowspan", "align", "valign"],
|
|
1322
|
+
tt: [],
|
|
1323
|
+
u: [],
|
|
1324
|
+
ul: [],
|
|
1325
|
+
video: [
|
|
1326
|
+
"autoplay",
|
|
1327
|
+
"controls",
|
|
1328
|
+
"crossorigin",
|
|
1329
|
+
"loop",
|
|
1330
|
+
"muted",
|
|
1331
|
+
"playsinline",
|
|
1332
|
+
"poster",
|
|
1333
|
+
"preload",
|
|
1334
|
+
"src",
|
|
1335
|
+
"height",
|
|
1336
|
+
"width"
|
|
1337
|
+
]
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
var defaultCSSFilter = new FilterCSS$1();
|
|
1341
|
+
function onTag(tag, html, options) {
|
|
1342
|
+
}
|
|
1343
|
+
function onIgnoreTag(tag, html, options) {
|
|
1344
|
+
}
|
|
1345
|
+
function onTagAttr(tag, name, value) {
|
|
1346
|
+
}
|
|
1347
|
+
function onIgnoreTagAttr(tag, name, value) {
|
|
1348
|
+
}
|
|
1349
|
+
function escapeHtml(html) {
|
|
1350
|
+
return html.replace(REGEXP_LT, "<").replace(REGEXP_GT, ">");
|
|
1351
|
+
}
|
|
1352
|
+
function safeAttrValue(tag, name, value, cssFilter) {
|
|
1353
|
+
value = friendlyAttrValue(value);
|
|
1354
|
+
if (name === "href" || name === "src") {
|
|
1355
|
+
value = _$2.trim(value);
|
|
1356
|
+
if (value === "#")
|
|
1357
|
+
return "#";
|
|
1358
|
+
if (!(value.substr(0, 7) === "http://" || value.substr(0, 8) === "https://" || value.substr(0, 7) === "mailto:" || value.substr(0, 4) === "tel:" || value.substr(0, 11) === "data:image/" || value.substr(0, 6) === "ftp://" || value.substr(0, 2) === "./" || value.substr(0, 3) === "../" || value[0] === "#" || value[0] === "/")) {
|
|
1359
|
+
return "";
|
|
1360
|
+
}
|
|
1361
|
+
} else if (name === "background") {
|
|
1362
|
+
REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
|
|
1363
|
+
if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
|
|
1364
|
+
return "";
|
|
1365
|
+
}
|
|
1366
|
+
} else if (name === "style") {
|
|
1367
|
+
REGEXP_DEFAULT_ON_TAG_ATTR_7.lastIndex = 0;
|
|
1368
|
+
if (REGEXP_DEFAULT_ON_TAG_ATTR_7.test(value)) {
|
|
1369
|
+
return "";
|
|
1370
|
+
}
|
|
1371
|
+
REGEXP_DEFAULT_ON_TAG_ATTR_8.lastIndex = 0;
|
|
1372
|
+
if (REGEXP_DEFAULT_ON_TAG_ATTR_8.test(value)) {
|
|
1373
|
+
REGEXP_DEFAULT_ON_TAG_ATTR_4.lastIndex = 0;
|
|
1374
|
+
if (REGEXP_DEFAULT_ON_TAG_ATTR_4.test(value)) {
|
|
1375
|
+
return "";
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
if (cssFilter !== false) {
|
|
1379
|
+
cssFilter = cssFilter || defaultCSSFilter;
|
|
1380
|
+
value = cssFilter.process(value);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
value = escapeAttrValue(value);
|
|
1384
|
+
return value;
|
|
1385
|
+
}
|
|
1386
|
+
var REGEXP_LT = /</g;
|
|
1387
|
+
var REGEXP_GT = />/g;
|
|
1388
|
+
var REGEXP_QUOTE = /"/g;
|
|
1389
|
+
var REGEXP_QUOTE_2 = /"/g;
|
|
1390
|
+
var REGEXP_ATTR_VALUE_1 = /&#([a-zA-Z0-9]*);?/gim;
|
|
1391
|
+
var REGEXP_ATTR_VALUE_COLON = /:?/gim;
|
|
1392
|
+
var REGEXP_ATTR_VALUE_NEWLINE = /&newline;?/gim;
|
|
1393
|
+
var REGEXP_DEFAULT_ON_TAG_ATTR_4 = /((j\s*a\s*v\s*a|v\s*b|l\s*i\s*v\s*e)\s*s\s*c\s*r\s*i\s*p\s*t\s*|m\s*o\s*c\s*h\s*a):/gi;
|
|
1394
|
+
var REGEXP_DEFAULT_ON_TAG_ATTR_7 = /e\s*x\s*p\s*r\s*e\s*s\s*s\s*i\s*o\s*n\s*\(.*/gi;
|
|
1395
|
+
var REGEXP_DEFAULT_ON_TAG_ATTR_8 = /u\s*r\s*l\s*\(.*/gi;
|
|
1396
|
+
function escapeQuote(str) {
|
|
1397
|
+
return str.replace(REGEXP_QUOTE, """);
|
|
1398
|
+
}
|
|
1399
|
+
function unescapeQuote(str) {
|
|
1400
|
+
return str.replace(REGEXP_QUOTE_2, '"');
|
|
1401
|
+
}
|
|
1402
|
+
function escapeHtmlEntities(str) {
|
|
1403
|
+
return str.replace(REGEXP_ATTR_VALUE_1, function replaceUnicode(str2, code) {
|
|
1404
|
+
return code[0] === "x" || code[0] === "X" ? String.fromCharCode(parseInt(code.substr(1), 16)) : String.fromCharCode(parseInt(code, 10));
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
function escapeDangerHtml5Entities(str) {
|
|
1408
|
+
return str.replace(REGEXP_ATTR_VALUE_COLON, ":").replace(REGEXP_ATTR_VALUE_NEWLINE, " ");
|
|
1409
|
+
}
|
|
1410
|
+
function clearNonPrintableCharacter(str) {
|
|
1411
|
+
var str2 = "";
|
|
1412
|
+
for (var i = 0, len = str.length; i < len; i++) {
|
|
1413
|
+
str2 += str.charCodeAt(i) < 32 ? " " : str.charAt(i);
|
|
1414
|
+
}
|
|
1415
|
+
return _$2.trim(str2);
|
|
1416
|
+
}
|
|
1417
|
+
function friendlyAttrValue(str) {
|
|
1418
|
+
str = unescapeQuote(str);
|
|
1419
|
+
str = escapeHtmlEntities(str);
|
|
1420
|
+
str = escapeDangerHtml5Entities(str);
|
|
1421
|
+
str = clearNonPrintableCharacter(str);
|
|
1422
|
+
return str;
|
|
1423
|
+
}
|
|
1424
|
+
function escapeAttrValue(str) {
|
|
1425
|
+
str = escapeQuote(str);
|
|
1426
|
+
str = escapeHtml(str);
|
|
1427
|
+
return str;
|
|
1428
|
+
}
|
|
1429
|
+
function onIgnoreTagStripAll() {
|
|
1430
|
+
return "";
|
|
1431
|
+
}
|
|
1432
|
+
function StripTagBody(tags, next) {
|
|
1433
|
+
if (typeof next !== "function") {
|
|
1434
|
+
next = function() {
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
var isRemoveAllTag = !Array.isArray(tags);
|
|
1438
|
+
function isRemoveTag(tag) {
|
|
1439
|
+
if (isRemoveAllTag)
|
|
1440
|
+
return true;
|
|
1441
|
+
return _$2.indexOf(tags, tag) !== -1;
|
|
1442
|
+
}
|
|
1443
|
+
var removeList = [];
|
|
1444
|
+
var posStart = false;
|
|
1445
|
+
return {
|
|
1446
|
+
onIgnoreTag: function(tag, html, options) {
|
|
1447
|
+
if (isRemoveTag(tag)) {
|
|
1448
|
+
if (options.isClosing) {
|
|
1449
|
+
var ret = "[/removed]";
|
|
1450
|
+
var end = options.position + ret.length;
|
|
1451
|
+
removeList.push([
|
|
1452
|
+
posStart !== false ? posStart : options.position,
|
|
1453
|
+
end
|
|
1454
|
+
]);
|
|
1455
|
+
posStart = false;
|
|
1456
|
+
return ret;
|
|
1457
|
+
} else {
|
|
1458
|
+
if (!posStart) {
|
|
1459
|
+
posStart = options.position;
|
|
1460
|
+
}
|
|
1461
|
+
return "[removed]";
|
|
1462
|
+
}
|
|
1463
|
+
} else {
|
|
1464
|
+
return next(tag, html, options);
|
|
1465
|
+
}
|
|
1466
|
+
},
|
|
1467
|
+
remove: function(html) {
|
|
1468
|
+
var rethtml = "";
|
|
1469
|
+
var lastPos = 0;
|
|
1470
|
+
_$2.forEach(removeList, function(pos) {
|
|
1471
|
+
rethtml += html.slice(lastPos, pos[0]);
|
|
1472
|
+
lastPos = pos[1];
|
|
1473
|
+
});
|
|
1474
|
+
rethtml += html.slice(lastPos);
|
|
1475
|
+
return rethtml;
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
function stripCommentTag(html) {
|
|
1480
|
+
var retHtml = "";
|
|
1481
|
+
var lastPos = 0;
|
|
1482
|
+
while (lastPos < html.length) {
|
|
1483
|
+
var i = html.indexOf("<!--", lastPos);
|
|
1484
|
+
if (i === -1) {
|
|
1485
|
+
retHtml += html.slice(lastPos);
|
|
1486
|
+
break;
|
|
1487
|
+
}
|
|
1488
|
+
retHtml += html.slice(lastPos, i);
|
|
1489
|
+
var j = html.indexOf("-->", i);
|
|
1490
|
+
if (j === -1) {
|
|
1491
|
+
break;
|
|
1492
|
+
}
|
|
1493
|
+
lastPos = j + 3;
|
|
1494
|
+
}
|
|
1495
|
+
return retHtml;
|
|
1496
|
+
}
|
|
1497
|
+
function stripBlankChar(html) {
|
|
1498
|
+
var chars = html.split("");
|
|
1499
|
+
chars = chars.filter(function(char) {
|
|
1500
|
+
var c = char.charCodeAt(0);
|
|
1501
|
+
if (c === 127)
|
|
1502
|
+
return false;
|
|
1503
|
+
if (c <= 31) {
|
|
1504
|
+
if (c === 10 || c === 13)
|
|
1505
|
+
return true;
|
|
1506
|
+
return false;
|
|
1507
|
+
}
|
|
1508
|
+
return true;
|
|
1509
|
+
});
|
|
1510
|
+
return chars.join("");
|
|
1511
|
+
}
|
|
1512
|
+
_default$1.whiteList = getDefaultWhiteList();
|
|
1513
|
+
_default$1.getDefaultWhiteList = getDefaultWhiteList;
|
|
1514
|
+
_default$1.onTag = onTag;
|
|
1515
|
+
_default$1.onIgnoreTag = onIgnoreTag;
|
|
1516
|
+
_default$1.onTagAttr = onTagAttr;
|
|
1517
|
+
_default$1.onIgnoreTagAttr = onIgnoreTagAttr;
|
|
1518
|
+
_default$1.safeAttrValue = safeAttrValue;
|
|
1519
|
+
_default$1.escapeHtml = escapeHtml;
|
|
1520
|
+
_default$1.escapeQuote = escapeQuote;
|
|
1521
|
+
_default$1.unescapeQuote = unescapeQuote;
|
|
1522
|
+
_default$1.escapeHtmlEntities = escapeHtmlEntities;
|
|
1523
|
+
_default$1.escapeDangerHtml5Entities = escapeDangerHtml5Entities;
|
|
1524
|
+
_default$1.clearNonPrintableCharacter = clearNonPrintableCharacter;
|
|
1525
|
+
_default$1.friendlyAttrValue = friendlyAttrValue;
|
|
1526
|
+
_default$1.escapeAttrValue = escapeAttrValue;
|
|
1527
|
+
_default$1.onIgnoreTagStripAll = onIgnoreTagStripAll;
|
|
1528
|
+
_default$1.StripTagBody = StripTagBody;
|
|
1529
|
+
_default$1.stripCommentTag = stripCommentTag;
|
|
1530
|
+
_default$1.stripBlankChar = stripBlankChar;
|
|
1531
|
+
_default$1.attributeWrapSign = '"';
|
|
1532
|
+
_default$1.cssFilter = defaultCSSFilter;
|
|
1533
|
+
_default$1.getDefaultCSSWhiteList = getDefaultCSSWhiteList;
|
|
1534
|
+
var parser$1 = {};
|
|
1535
|
+
var _$1 = util;
|
|
1536
|
+
function getTagName(html) {
|
|
1537
|
+
var i = _$1.spaceIndex(html);
|
|
1538
|
+
var tagName;
|
|
1539
|
+
if (i === -1) {
|
|
1540
|
+
tagName = html.slice(1, -1);
|
|
1541
|
+
} else {
|
|
1542
|
+
tagName = html.slice(1, i + 1);
|
|
1543
|
+
}
|
|
1544
|
+
tagName = _$1.trim(tagName).toLowerCase();
|
|
1545
|
+
if (tagName.slice(0, 1) === "/")
|
|
1546
|
+
tagName = tagName.slice(1);
|
|
1547
|
+
if (tagName.slice(-1) === "/")
|
|
1548
|
+
tagName = tagName.slice(0, -1);
|
|
1549
|
+
return tagName;
|
|
1550
|
+
}
|
|
1551
|
+
function isClosing(html) {
|
|
1552
|
+
return html.slice(0, 2) === "</";
|
|
1553
|
+
}
|
|
1554
|
+
function parseTag$1(html, onTag2, escapeHtml2) {
|
|
1555
|
+
var rethtml = "";
|
|
1556
|
+
var lastPos = 0;
|
|
1557
|
+
var tagStart = false;
|
|
1558
|
+
var quoteStart = false;
|
|
1559
|
+
var currentPos = 0;
|
|
1560
|
+
var len = html.length;
|
|
1561
|
+
var currentTagName = "";
|
|
1562
|
+
var currentHtml = "";
|
|
1563
|
+
chariterator:
|
|
1564
|
+
for (currentPos = 0; currentPos < len; currentPos++) {
|
|
1565
|
+
var c = html.charAt(currentPos);
|
|
1566
|
+
if (tagStart === false) {
|
|
1567
|
+
if (c === "<") {
|
|
1568
|
+
tagStart = currentPos;
|
|
1569
|
+
continue;
|
|
1570
|
+
}
|
|
1571
|
+
} else {
|
|
1572
|
+
if (quoteStart === false) {
|
|
1573
|
+
if (c === "<") {
|
|
1574
|
+
rethtml += escapeHtml2(html.slice(lastPos, currentPos));
|
|
1575
|
+
tagStart = currentPos;
|
|
1576
|
+
lastPos = currentPos;
|
|
1577
|
+
continue;
|
|
1578
|
+
}
|
|
1579
|
+
if (c === ">" || currentPos === len - 1) {
|
|
1580
|
+
rethtml += escapeHtml2(html.slice(lastPos, tagStart));
|
|
1581
|
+
currentHtml = html.slice(tagStart, currentPos + 1);
|
|
1582
|
+
currentTagName = getTagName(currentHtml);
|
|
1583
|
+
rethtml += onTag2(
|
|
1584
|
+
tagStart,
|
|
1585
|
+
rethtml.length,
|
|
1586
|
+
currentTagName,
|
|
1587
|
+
currentHtml,
|
|
1588
|
+
isClosing(currentHtml)
|
|
1589
|
+
);
|
|
1590
|
+
lastPos = currentPos + 1;
|
|
1591
|
+
tagStart = false;
|
|
1592
|
+
continue;
|
|
1593
|
+
}
|
|
1594
|
+
if (c === '"' || c === "'") {
|
|
1595
|
+
var i = 1;
|
|
1596
|
+
var ic = html.charAt(currentPos - i);
|
|
1597
|
+
while (ic.trim() === "" || ic === "=") {
|
|
1598
|
+
if (ic === "=") {
|
|
1599
|
+
quoteStart = c;
|
|
1600
|
+
continue chariterator;
|
|
1601
|
+
}
|
|
1602
|
+
ic = html.charAt(currentPos - ++i);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
} else {
|
|
1606
|
+
if (c === quoteStart) {
|
|
1607
|
+
quoteStart = false;
|
|
1608
|
+
continue;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
if (lastPos < len) {
|
|
1614
|
+
rethtml += escapeHtml2(html.substr(lastPos));
|
|
1615
|
+
}
|
|
1616
|
+
return rethtml;
|
|
1617
|
+
}
|
|
1618
|
+
var REGEXP_ILLEGAL_ATTR_NAME = /[^a-zA-Z0-9\\_:.-]/gim;
|
|
1619
|
+
function parseAttr$1(html, onAttr2) {
|
|
1620
|
+
var lastPos = 0;
|
|
1621
|
+
var lastMarkPos = 0;
|
|
1622
|
+
var retAttrs = [];
|
|
1623
|
+
var tmpName = false;
|
|
1624
|
+
var len = html.length;
|
|
1625
|
+
function addAttr(name, value) {
|
|
1626
|
+
name = _$1.trim(name);
|
|
1627
|
+
name = name.replace(REGEXP_ILLEGAL_ATTR_NAME, "").toLowerCase();
|
|
1628
|
+
if (name.length < 1)
|
|
1629
|
+
return;
|
|
1630
|
+
var ret = onAttr2(name, value || "");
|
|
1631
|
+
if (ret)
|
|
1632
|
+
retAttrs.push(ret);
|
|
1633
|
+
}
|
|
1634
|
+
for (var i = 0; i < len; i++) {
|
|
1635
|
+
var c = html.charAt(i);
|
|
1636
|
+
var v, j;
|
|
1637
|
+
if (tmpName === false && c === "=") {
|
|
1638
|
+
tmpName = html.slice(lastPos, i);
|
|
1639
|
+
lastPos = i + 1;
|
|
1640
|
+
lastMarkPos = html.charAt(lastPos) === '"' || html.charAt(lastPos) === "'" ? lastPos : findNextQuotationMark(html, i + 1);
|
|
1641
|
+
continue;
|
|
1642
|
+
}
|
|
1643
|
+
if (tmpName !== false) {
|
|
1644
|
+
if (i === lastMarkPos) {
|
|
1645
|
+
j = html.indexOf(c, i + 1);
|
|
1646
|
+
if (j === -1) {
|
|
1647
|
+
break;
|
|
1648
|
+
} else {
|
|
1649
|
+
v = _$1.trim(html.slice(lastMarkPos + 1, j));
|
|
1650
|
+
addAttr(tmpName, v);
|
|
1651
|
+
tmpName = false;
|
|
1652
|
+
i = j;
|
|
1653
|
+
lastPos = i + 1;
|
|
1654
|
+
continue;
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
if (/\s|\n|\t/.test(c)) {
|
|
1659
|
+
html = html.replace(/\s|\n|\t/g, " ");
|
|
1660
|
+
if (tmpName === false) {
|
|
1661
|
+
j = findNextEqual(html, i);
|
|
1662
|
+
if (j === -1) {
|
|
1663
|
+
v = _$1.trim(html.slice(lastPos, i));
|
|
1664
|
+
addAttr(v);
|
|
1665
|
+
tmpName = false;
|
|
1666
|
+
lastPos = i + 1;
|
|
1667
|
+
continue;
|
|
1668
|
+
} else {
|
|
1669
|
+
i = j - 1;
|
|
1670
|
+
continue;
|
|
1671
|
+
}
|
|
1672
|
+
} else {
|
|
1673
|
+
j = findBeforeEqual(html, i - 1);
|
|
1674
|
+
if (j === -1) {
|
|
1675
|
+
v = _$1.trim(html.slice(lastPos, i));
|
|
1676
|
+
v = stripQuoteWrap(v);
|
|
1677
|
+
addAttr(tmpName, v);
|
|
1678
|
+
tmpName = false;
|
|
1679
|
+
lastPos = i + 1;
|
|
1680
|
+
continue;
|
|
1681
|
+
} else {
|
|
1682
|
+
continue;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
if (lastPos < html.length) {
|
|
1688
|
+
if (tmpName === false) {
|
|
1689
|
+
addAttr(html.slice(lastPos));
|
|
1690
|
+
} else {
|
|
1691
|
+
addAttr(tmpName, stripQuoteWrap(_$1.trim(html.slice(lastPos))));
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
return _$1.trim(retAttrs.join(" "));
|
|
1695
|
+
}
|
|
1696
|
+
function findNextEqual(str, i) {
|
|
1697
|
+
for (; i < str.length; i++) {
|
|
1698
|
+
var c = str[i];
|
|
1699
|
+
if (c === " ")
|
|
1700
|
+
continue;
|
|
1701
|
+
if (c === "=")
|
|
1702
|
+
return i;
|
|
1703
|
+
return -1;
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
function findNextQuotationMark(str, i) {
|
|
1707
|
+
for (; i < str.length; i++) {
|
|
1708
|
+
var c = str[i];
|
|
1709
|
+
if (c === " ")
|
|
1710
|
+
continue;
|
|
1711
|
+
if (c === "'" || c === '"')
|
|
1712
|
+
return i;
|
|
1713
|
+
return -1;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
function findBeforeEqual(str, i) {
|
|
1717
|
+
for (; i > 0; i--) {
|
|
1718
|
+
var c = str[i];
|
|
1719
|
+
if (c === " ")
|
|
1720
|
+
continue;
|
|
1721
|
+
if (c === "=")
|
|
1722
|
+
return i;
|
|
1723
|
+
return -1;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
function isQuoteWrapString(text) {
|
|
1727
|
+
if (text[0] === '"' && text[text.length - 1] === '"' || text[0] === "'" && text[text.length - 1] === "'") {
|
|
1728
|
+
return true;
|
|
1729
|
+
} else {
|
|
1730
|
+
return false;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
function stripQuoteWrap(text) {
|
|
1734
|
+
if (isQuoteWrapString(text)) {
|
|
1735
|
+
return text.substr(1, text.length - 2);
|
|
1736
|
+
} else {
|
|
1737
|
+
return text;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
parser$1.parseTag = parseTag$1;
|
|
1741
|
+
parser$1.parseAttr = parseAttr$1;
|
|
1742
|
+
var FilterCSS = libExports$1.FilterCSS;
|
|
1743
|
+
var DEFAULT = _default$1;
|
|
1744
|
+
var parser = parser$1;
|
|
1745
|
+
var parseTag = parser.parseTag;
|
|
1746
|
+
var parseAttr = parser.parseAttr;
|
|
1747
|
+
var _ = util;
|
|
1748
|
+
function isNull(obj) {
|
|
1749
|
+
return obj === void 0 || obj === null;
|
|
1750
|
+
}
|
|
1751
|
+
function getAttrs(html) {
|
|
1752
|
+
var i = _.spaceIndex(html);
|
|
1753
|
+
if (i === -1) {
|
|
1754
|
+
return {
|
|
1755
|
+
html: "",
|
|
1756
|
+
closing: html[html.length - 2] === "/"
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
html = _.trim(html.slice(i + 1, -1));
|
|
1760
|
+
var isClosing2 = html[html.length - 1] === "/";
|
|
1761
|
+
if (isClosing2)
|
|
1762
|
+
html = _.trim(html.slice(0, -1));
|
|
1763
|
+
return {
|
|
1764
|
+
html,
|
|
1765
|
+
closing: isClosing2
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
function shallowCopyObject(obj) {
|
|
1769
|
+
var ret = {};
|
|
1770
|
+
for (var i in obj) {
|
|
1771
|
+
ret[i] = obj[i];
|
|
1772
|
+
}
|
|
1773
|
+
return ret;
|
|
1774
|
+
}
|
|
1775
|
+
function keysToLowerCase(obj) {
|
|
1776
|
+
var ret = {};
|
|
1777
|
+
for (var i in obj) {
|
|
1778
|
+
if (Array.isArray(obj[i])) {
|
|
1779
|
+
ret[i.toLowerCase()] = obj[i].map(function(item) {
|
|
1780
|
+
return item.toLowerCase();
|
|
1781
|
+
});
|
|
1782
|
+
} else {
|
|
1783
|
+
ret[i.toLowerCase()] = obj[i];
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
return ret;
|
|
1787
|
+
}
|
|
1788
|
+
function FilterXSS(options) {
|
|
1789
|
+
options = shallowCopyObject(options || {});
|
|
1790
|
+
if (options.stripIgnoreTag) {
|
|
1791
|
+
if (options.onIgnoreTag) {
|
|
1792
|
+
console.error(
|
|
1793
|
+
'Notes: cannot use these two options "stripIgnoreTag" and "onIgnoreTag" at the same time'
|
|
1794
|
+
);
|
|
1795
|
+
}
|
|
1796
|
+
options.onIgnoreTag = DEFAULT.onIgnoreTagStripAll;
|
|
1797
|
+
}
|
|
1798
|
+
if (options.whiteList || options.allowList) {
|
|
1799
|
+
options.whiteList = keysToLowerCase(options.whiteList || options.allowList);
|
|
1800
|
+
} else {
|
|
1801
|
+
options.whiteList = DEFAULT.whiteList;
|
|
1802
|
+
}
|
|
1803
|
+
this.attributeWrapSign = options.singleQuotedAttributeValue === true ? "'" : DEFAULT.attributeWrapSign;
|
|
1804
|
+
options.onTag = options.onTag || DEFAULT.onTag;
|
|
1805
|
+
options.onTagAttr = options.onTagAttr || DEFAULT.onTagAttr;
|
|
1806
|
+
options.onIgnoreTag = options.onIgnoreTag || DEFAULT.onIgnoreTag;
|
|
1807
|
+
options.onIgnoreTagAttr = options.onIgnoreTagAttr || DEFAULT.onIgnoreTagAttr;
|
|
1808
|
+
options.safeAttrValue = options.safeAttrValue || DEFAULT.safeAttrValue;
|
|
1809
|
+
options.escapeHtml = options.escapeHtml || DEFAULT.escapeHtml;
|
|
1810
|
+
this.options = options;
|
|
1811
|
+
if (options.css === false) {
|
|
1812
|
+
this.cssFilter = false;
|
|
1813
|
+
} else {
|
|
1814
|
+
options.css = options.css || {};
|
|
1815
|
+
this.cssFilter = new FilterCSS(options.css);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
FilterXSS.prototype.process = function(html) {
|
|
1819
|
+
html = html || "";
|
|
1820
|
+
html = html.toString();
|
|
1821
|
+
if (!html)
|
|
1822
|
+
return "";
|
|
1823
|
+
var me = this;
|
|
1824
|
+
var options = me.options;
|
|
1825
|
+
var whiteList = options.whiteList;
|
|
1826
|
+
var onTag2 = options.onTag;
|
|
1827
|
+
var onIgnoreTag2 = options.onIgnoreTag;
|
|
1828
|
+
var onTagAttr2 = options.onTagAttr;
|
|
1829
|
+
var onIgnoreTagAttr2 = options.onIgnoreTagAttr;
|
|
1830
|
+
var safeAttrValue2 = options.safeAttrValue;
|
|
1831
|
+
var escapeHtml2 = options.escapeHtml;
|
|
1832
|
+
var attributeWrapSign = me.attributeWrapSign;
|
|
1833
|
+
var cssFilter = me.cssFilter;
|
|
1834
|
+
if (options.stripBlankChar) {
|
|
1835
|
+
html = DEFAULT.stripBlankChar(html);
|
|
1836
|
+
}
|
|
1837
|
+
if (!options.allowCommentTag) {
|
|
1838
|
+
html = DEFAULT.stripCommentTag(html);
|
|
1839
|
+
}
|
|
1840
|
+
var stripIgnoreTagBody = false;
|
|
1841
|
+
if (options.stripIgnoreTagBody) {
|
|
1842
|
+
stripIgnoreTagBody = DEFAULT.StripTagBody(
|
|
1843
|
+
options.stripIgnoreTagBody,
|
|
1844
|
+
onIgnoreTag2
|
|
1845
|
+
);
|
|
1846
|
+
onIgnoreTag2 = stripIgnoreTagBody.onIgnoreTag;
|
|
1847
|
+
}
|
|
1848
|
+
var retHtml = parseTag(
|
|
1849
|
+
html,
|
|
1850
|
+
function(sourcePosition, position, tag, html2, isClosing2) {
|
|
1851
|
+
var info = {
|
|
1852
|
+
sourcePosition,
|
|
1853
|
+
position,
|
|
1854
|
+
isClosing: isClosing2,
|
|
1855
|
+
isWhite: Object.prototype.hasOwnProperty.call(whiteList, tag)
|
|
1856
|
+
};
|
|
1857
|
+
var ret = onTag2(tag, html2, info);
|
|
1858
|
+
if (!isNull(ret))
|
|
1859
|
+
return ret;
|
|
1860
|
+
if (info.isWhite) {
|
|
1861
|
+
if (info.isClosing) {
|
|
1862
|
+
return "</" + tag + ">";
|
|
1863
|
+
}
|
|
1864
|
+
var attrs = getAttrs(html2);
|
|
1865
|
+
var whiteAttrList = whiteList[tag];
|
|
1866
|
+
var attrsHtml = parseAttr(attrs.html, function(name, value) {
|
|
1867
|
+
var isWhiteAttr = _.indexOf(whiteAttrList, name) !== -1;
|
|
1868
|
+
var ret2 = onTagAttr2(tag, name, value, isWhiteAttr);
|
|
1869
|
+
if (!isNull(ret2))
|
|
1870
|
+
return ret2;
|
|
1871
|
+
if (isWhiteAttr) {
|
|
1872
|
+
value = safeAttrValue2(tag, name, value, cssFilter);
|
|
1873
|
+
if (value) {
|
|
1874
|
+
return name + "=" + attributeWrapSign + value + attributeWrapSign;
|
|
1875
|
+
} else {
|
|
1876
|
+
return name;
|
|
1877
|
+
}
|
|
1878
|
+
} else {
|
|
1879
|
+
ret2 = onIgnoreTagAttr2(tag, name, value, isWhiteAttr);
|
|
1880
|
+
if (!isNull(ret2))
|
|
1881
|
+
return ret2;
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
});
|
|
1885
|
+
html2 = "<" + tag;
|
|
1886
|
+
if (attrsHtml)
|
|
1887
|
+
html2 += " " + attrsHtml;
|
|
1888
|
+
if (attrs.closing)
|
|
1889
|
+
html2 += " /";
|
|
1890
|
+
html2 += ">";
|
|
1891
|
+
return html2;
|
|
1892
|
+
} else {
|
|
1893
|
+
ret = onIgnoreTag2(tag, html2, info);
|
|
1894
|
+
if (!isNull(ret))
|
|
1895
|
+
return ret;
|
|
1896
|
+
return escapeHtml2(html2);
|
|
1897
|
+
}
|
|
1898
|
+
},
|
|
1899
|
+
escapeHtml2
|
|
1900
|
+
);
|
|
1901
|
+
if (stripIgnoreTagBody) {
|
|
1902
|
+
retHtml = stripIgnoreTagBody.remove(retHtml);
|
|
1903
|
+
}
|
|
1904
|
+
return retHtml;
|
|
1905
|
+
};
|
|
1906
|
+
var xss$1 = FilterXSS;
|
|
1907
|
+
(function(module, exports) {
|
|
1908
|
+
var DEFAULT2 = _default$1;
|
|
1909
|
+
var parser2 = parser$1;
|
|
1910
|
+
var FilterXSS2 = xss$1;
|
|
1911
|
+
function filterXSS(html, options) {
|
|
1912
|
+
var xss2 = new FilterXSS2(options);
|
|
1913
|
+
return xss2.process(html);
|
|
1914
|
+
}
|
|
1915
|
+
exports = module.exports = filterXSS;
|
|
1916
|
+
exports.filterXSS = filterXSS;
|
|
1917
|
+
exports.FilterXSS = FilterXSS2;
|
|
1918
|
+
(function() {
|
|
1919
|
+
for (var i in DEFAULT2) {
|
|
1920
|
+
exports[i] = DEFAULT2[i];
|
|
1921
|
+
}
|
|
1922
|
+
for (var j in parser2) {
|
|
1923
|
+
exports[j] = parser2[j];
|
|
1924
|
+
}
|
|
1925
|
+
})();
|
|
1926
|
+
if (typeof window !== "undefined") {
|
|
1927
|
+
window.filterXSS = module.exports;
|
|
1928
|
+
}
|
|
1929
|
+
function isWorkerEnv() {
|
|
1930
|
+
return typeof self !== "undefined" && typeof DedicatedWorkerGlobalScope !== "undefined" && self instanceof DedicatedWorkerGlobalScope;
|
|
1931
|
+
}
|
|
1932
|
+
if (isWorkerEnv()) {
|
|
1933
|
+
self.filterXSS = module.exports;
|
|
1934
|
+
}
|
|
1935
|
+
})(lib$1, lib$1.exports);
|
|
1936
|
+
var libExports = lib$1.exports;
|
|
1937
|
+
const index = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
|
|
1938
|
+
const xss = /* @__PURE__ */ _mergeNamespaces({
|
|
1939
|
+
__proto__: null,
|
|
1940
|
+
default: index
|
|
1941
|
+
}, [libExports]);
|
|
1942
|
+
const MdWhiteList = {
|
|
1943
|
+
img: ["class"],
|
|
1944
|
+
// 支持任务列表
|
|
1945
|
+
input: ["class", "disabled", "type", "checked"],
|
|
1946
|
+
// 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码
|
|
1947
|
+
iframe: [
|
|
1948
|
+
"class",
|
|
1949
|
+
"width",
|
|
1950
|
+
"height",
|
|
1951
|
+
"src",
|
|
1952
|
+
"title",
|
|
1953
|
+
"border",
|
|
1954
|
+
"frameborder",
|
|
1955
|
+
"framespacing",
|
|
1956
|
+
"allow",
|
|
1957
|
+
"allowfullscreen"
|
|
1958
|
+
]
|
|
1959
|
+
};
|
|
1960
|
+
const XSSPlugin = (md, options) => {
|
|
1961
|
+
const { extendedWhiteList = {}, xss: xssOption = {} } = options;
|
|
1962
|
+
let xssIns;
|
|
1963
|
+
if (typeof xssOption === "function") {
|
|
1964
|
+
xssIns = new libExports.FilterXSS(xssOption(xss));
|
|
1965
|
+
} else {
|
|
1966
|
+
const whiteList = libExports.getDefaultWhiteList();
|
|
1967
|
+
const keys = [...Object.keys(extendedWhiteList), ...Object.keys(MdWhiteList)];
|
|
1968
|
+
keys.forEach((key) => {
|
|
1969
|
+
const xssWhiteItem = whiteList[key] || [];
|
|
1970
|
+
const innerWhiteItem = MdWhiteList[key] || [];
|
|
1971
|
+
const userDefWhiteItem = extendedWhiteList[key] || [];
|
|
1972
|
+
whiteList[key] = [
|
|
1973
|
+
.../* @__PURE__ */ new Set([...xssWhiteItem, ...innerWhiteItem, ...userDefWhiteItem])
|
|
1974
|
+
];
|
|
1975
|
+
});
|
|
1976
|
+
xssIns = new libExports.FilterXSS({
|
|
1977
|
+
whiteList,
|
|
1978
|
+
// 自定义的优先级最高
|
|
1979
|
+
...xssOption
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
md.core.ruler.after("linkify", "xss", (state) => {
|
|
1983
|
+
for (let i = 0; i < state.tokens.length; i++) {
|
|
1984
|
+
const cur = state.tokens[i];
|
|
1985
|
+
switch (cur.type) {
|
|
1986
|
+
case "html_block": {
|
|
1987
|
+
cur.content = xssIns.process(cur.content);
|
|
1988
|
+
break;
|
|
1989
|
+
}
|
|
1990
|
+
case "inline": {
|
|
1991
|
+
const inlineTokens = cur.children || [];
|
|
1992
|
+
inlineTokens.forEach((it) => {
|
|
1993
|
+
if (it.type === "html_inline") {
|
|
1994
|
+
it.content = xssIns.process(it.content);
|
|
1995
|
+
}
|
|
1996
|
+
});
|
|
1997
|
+
break;
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
});
|
|
2002
|
+
};
|
|
2003
|
+
const XSSPlugin$1 = XSSPlugin;
|
|
661
2004
|
const initLineNumber = (md) => {
|
|
662
2005
|
md.core.ruler.push("init-line-number", (state) => {
|
|
663
2006
|
state.tokens.forEach((token) => {
|
|
@@ -725,31 +2068,8 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
725
2068
|
},
|
|
726
2069
|
{
|
|
727
2070
|
type: "xss",
|
|
728
|
-
plugin: XSSPlugin,
|
|
729
|
-
options: {
|
|
730
|
-
// https://github.com/leizongmin/js-xss/blob/master/README.zh.md
|
|
731
|
-
xss(xss) {
|
|
732
|
-
return {
|
|
733
|
-
whiteList: Object.assign({}, xss.getDefaultWhiteList(), {
|
|
734
|
-
// 支持任务列表
|
|
735
|
-
input: ["class", "disabled", "type", "checked"],
|
|
736
|
-
// 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码
|
|
737
|
-
iframe: [
|
|
738
|
-
"class",
|
|
739
|
-
"width",
|
|
740
|
-
"height",
|
|
741
|
-
"src",
|
|
742
|
-
"title",
|
|
743
|
-
"border",
|
|
744
|
-
"frameborder",
|
|
745
|
-
"framespacing",
|
|
746
|
-
"allow",
|
|
747
|
-
"allowfullscreen"
|
|
748
|
-
]
|
|
749
|
-
})
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
}
|
|
2071
|
+
plugin: XSSPlugin$1,
|
|
2072
|
+
options: {}
|
|
753
2073
|
}
|
|
754
2074
|
];
|
|
755
2075
|
if (!props.noKatex) {
|
|
@@ -798,9 +2118,7 @@ const useMarkdownIt = (props, previewOnly) => {
|
|
|
798
2118
|
return `<pre><code class="language-${language}" language=${language}>${codeSpan}</code></pre>`;
|
|
799
2119
|
}
|
|
800
2120
|
});
|
|
801
|
-
|
|
802
|
-
initLineNumber(md);
|
|
803
|
-
}
|
|
2121
|
+
initLineNumber(md);
|
|
804
2122
|
const key = ref(`_article-key_${uuid()}`);
|
|
805
2123
|
const html = ref(props.sanitize(md.render(props.modelValue)));
|
|
806
2124
|
const updatedTodo = () => {
|
|
@@ -1167,9 +2485,9 @@ const useExpansion = (props) => {
|
|
|
1167
2485
|
const noCropperScript = noUploadImg || editorExtensions.cropper.instance;
|
|
1168
2486
|
onMounted(() => {
|
|
1169
2487
|
if (!noCropperScript) {
|
|
1170
|
-
const { js = {}, css = {} } = editorExtensionsAttrs.cropper || {};
|
|
2488
|
+
const { js = {}, css: css2 = {} } = editorExtensionsAttrs.cropper || {};
|
|
1171
2489
|
appendHandler("link", {
|
|
1172
|
-
...
|
|
2490
|
+
...css2,
|
|
1173
2491
|
rel: "stylesheet",
|
|
1174
2492
|
href: editorExtensions.cropper.css,
|
|
1175
2493
|
id: `${prefix}-cropperCss`
|