@aiquants/markdown-explorer 0.11.0 → 0.12.1
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/CHANGELOG.md +27 -1
- package/README.md +65 -6
- package/dist/EditSurface-By6NPcD7.js +633 -0
- package/dist/EditSurface-BztcpQPW.cjs +2 -0
- package/dist/{ExplorerSplit-DwlWWfRv.js → ExplorerSplit-BjjqNRtj.js} +52 -52
- package/dist/{ExplorerSplit-51frK8xf.cjs → ExplorerSplit-CqmbUSZ7.cjs} +1 -1
- package/dist/{MultiLayout-CeR_l6Rb.js → MultiLayout-BYXoD1aS.js} +4 -4
- package/dist/{MultiLayout-B4PtS45V.cjs → MultiLayout-BZbEl73E.cjs} +1 -1
- package/dist/{NativeScrollBar-Dp4YWBp7.cjs → NativeScrollBar-B7jTbQmn.cjs} +1 -1
- package/dist/{NativeScrollBar-CVWeTlHC.js → NativeScrollBar-RP37nwmY.js} +1 -1
- package/dist/{TreeLayout-D-NyhuVM.cjs → TreeLayout-CEp5oKly.cjs} +1 -1
- package/dist/{TreeLayout-min5AOhr.js → TreeLayout-Uo6RG7lq.js} +3 -3
- package/dist/client/MarkdownExplorer.d.cts +3 -2
- package/dist/client/MarkdownExplorer.d.ts +3 -2
- package/dist/core/contracts.d.cts +16 -0
- package/dist/core/contracts.d.ts +16 -0
- package/dist/dataRoute-CH3yOKR0.cjs +1 -0
- package/dist/{dataRoute-CU9CKP44.js → dataRoute-Pm_0ue_4.js} +93 -92
- package/dist/{index-DJ_FUtYM.cjs → index-CGBl3fYT.cjs} +8 -8
- package/dist/{index-BPj19kIo.js → index-CjCr8czx.js} +962 -908
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -9
- package/dist/{location-LNl0QOXI.cjs → location-BUNWJ4eB.cjs} +1 -1
- package/dist/{location-BT23fKeh.js → location-DWd6SQhN.js} +1 -1
- package/dist/{merge-AnqxGn__.cjs → merge-DRGBbLuR.cjs} +1 -1
- package/dist/{merge-hyUGPGbJ.js → merge-q-5i8qsn.js} +1 -1
- package/dist/sanitizePolicy-BfUlXI5E.cjs +1 -0
- package/dist/sanitizePolicy-djLC3fRN.js +96 -0
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +143 -226
- package/dist/server.cjs +1 -1
- package/dist/server.js +3 -3
- package/dist/styles/markdown-explorer.css +1 -1
- package/docs/behavior/dom-hooks.md +1 -1
- package/docs/behavior/layout.md +4 -1
- package/docs/behavior/security.md +2 -0
- package/package.json +3 -3
- package/dist/EditSurface-BK_Pz_LF.js +0 -371
- package/dist/EditSurface-CfbYYXrc.cjs +0 -2
- package/dist/dataRoute-CIFFX5bd.cjs +0 -1
package/dist/sanitizeWorker.js
CHANGED
|
@@ -1,282 +1,199 @@
|
|
|
1
|
-
import { parentPort as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const G = 512, fe = 4096, j = 1024, V = /* @__PURE__ */ Symbol("placement"), W = 2, de = 3, pe = /* @__PURE__ */ new Set(["html", "head", "body"]), w = 0, D = 1, M = 2, Q = 3, z = 4, O = 5, k = 6, b = 7, $ = 8, I = 9, X = 10, _ = -1, Ee = 0, me = 1, Te = 2, he = 3, Ae = 4, ge = 5, Y = 6, Se = 7, _e = (r) => {
|
|
8
|
-
switch (r) {
|
|
1
|
+
import { parentPort as W } from "node:worker_threads";
|
|
2
|
+
import q from "isomorphic-dompurify";
|
|
3
|
+
import { M as D, c as K, H as Y } from "./sanitizePolicy-djLC3fRN.js";
|
|
4
|
+
import { defaultTreeAdapter as w, parse as Z, html as ee } from "parse5";
|
|
5
|
+
const te = 4096, P = 1024, B = /* @__PURE__ */ Symbol("placement"), G = 2, re = 3, ne = /* @__PURE__ */ new Set(["html", "head", "body"]), A = 0, L = 1, M = 2, z = 3, U = 4, C = 5, N = 6, _ = 7, F = 8, b = 9, Q = 10, T = -1, oe = 0, se = 1, ae = 2, ie = 3, ce = 4, le = 5, j = 6, ue = 7, fe = (t) => {
|
|
6
|
+
switch (t) {
|
|
9
7
|
case 9:
|
|
10
8
|
case 10:
|
|
11
9
|
case 12:
|
|
12
10
|
case 13:
|
|
13
11
|
case 32:
|
|
14
|
-
return
|
|
12
|
+
return oe;
|
|
15
13
|
case 47:
|
|
16
|
-
return
|
|
14
|
+
return se;
|
|
17
15
|
case 62:
|
|
18
|
-
return
|
|
16
|
+
return ae;
|
|
19
17
|
case 61:
|
|
20
|
-
return
|
|
18
|
+
return ie;
|
|
21
19
|
case 34:
|
|
22
|
-
return
|
|
20
|
+
return ce;
|
|
23
21
|
case 39:
|
|
24
|
-
return
|
|
22
|
+
return le;
|
|
25
23
|
default:
|
|
26
|
-
return
|
|
24
|
+
return j;
|
|
27
25
|
}
|
|
28
|
-
},
|
|
26
|
+
}, he = Uint8Array.from({ length: 128 }, (t, i) => fe(i)), I = 60, V = 47, Ee = /[\t\n\f\r />="'<]/g, de = /["<]/g, pe = /['<]/g, f = -1 - M, ge = Int8Array.from(
|
|
29
27
|
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
28
|
+
[L, b, T, A, A, A, A],
|
|
29
|
+
[L, b, T, f, f, f, f],
|
|
30
|
+
[z, b, T, U, M, M, M],
|
|
31
|
+
[z, b, T, U, f, f, f],
|
|
32
|
+
[U, _, T, _, C, N, _],
|
|
33
|
+
[C, C, C, C, F, C, C],
|
|
34
|
+
[N, N, N, N, N, F, N],
|
|
35
|
+
[L, _, T, _, _, _, _],
|
|
36
|
+
[L, b, T, f, f, f, f],
|
|
37
|
+
[L, b, T, f, f, f, f]
|
|
40
38
|
].flat()
|
|
41
|
-
),
|
|
42
|
-
let
|
|
43
|
-
for (; n <
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
n =
|
|
39
|
+
), $ = (t) => t >= 65 && t <= 90 || t >= 97 && t <= 122, me = (t, i) => {
|
|
40
|
+
let c = new Int32Array(Q), l = new Int32Array(Q), s = 0, p = 0, n = 0;
|
|
41
|
+
for (; n < t.length; ) {
|
|
42
|
+
if (s === 0) {
|
|
43
|
+
const u = t.indexOf("<", n);
|
|
44
|
+
if (u < 0) return !1;
|
|
45
|
+
n = u + 1, t.charCodeAt(n) === V && (n += 1), $(t.charCodeAt(n)) && (c[A] = 0, s = 1 << A, n += 1);
|
|
48
46
|
continue;
|
|
49
47
|
}
|
|
50
|
-
if ((
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
n =
|
|
48
|
+
if ((s & -230) === 0 && n >= p) {
|
|
49
|
+
const u = s === 1 << C ? de : s === 1 << N ? pe : Ee;
|
|
50
|
+
u.lastIndex = n;
|
|
51
|
+
const S = u.exec(t);
|
|
52
|
+
if (S === null) return !1;
|
|
53
|
+
n = S.index, t.charCodeAt(n) === I && (p = n + 3);
|
|
56
54
|
}
|
|
57
|
-
const
|
|
58
|
-
let
|
|
59
|
-
for (let
|
|
60
|
-
const
|
|
61
|
-
let
|
|
62
|
-
if (
|
|
55
|
+
const h = t.charCodeAt(n), m = h < 128 ? he[h] : j;
|
|
56
|
+
let d = 0;
|
|
57
|
+
for (let u = s; u !== 0; u &= u - 1) {
|
|
58
|
+
const S = 31 - Math.clz32(u & -u);
|
|
59
|
+
let g = ge[S * ue + m], E = c[S];
|
|
60
|
+
if (g < T && (g = -1 - g, E += 1, E > i))
|
|
63
61
|
return !0;
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
((
|
|
62
|
+
if (g === T) continue;
|
|
63
|
+
const v = 1 << g;
|
|
64
|
+
((d & v) === 0 || E > l[g]) && (l[g] = E), d |= v;
|
|
67
65
|
}
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
66
|
+
$(h) && (t.charCodeAt(n - 1) === I || t.charCodeAt(n - 1) === V && t.charCodeAt(n - 2) === I) && (d & 1 << A) === 0 && (l[A] = 0, d |= 1 << A);
|
|
67
|
+
const y = c;
|
|
68
|
+
c = l, l = y, s = d, n += 1;
|
|
71
69
|
}
|
|
72
70
|
return !1;
|
|
73
71
|
};
|
|
74
|
-
class
|
|
72
|
+
class O extends Error {
|
|
75
73
|
status;
|
|
76
74
|
constructor(i) {
|
|
77
75
|
super(`[markdown-explorer] the nesting guard stopped the parse: ${i}`), this.name = "ParseStop", this.status = i;
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
|
-
const
|
|
78
|
+
const Te = (t, i, c, l) => {
|
|
81
79
|
if (!Number.isSafeInteger(i) || i <= 0) throw new RangeError(`[markdown-explorer] the nesting guard's depth limit must be a positive safe integer; got ${String(i)}`);
|
|
82
|
-
if (!Number.isSafeInteger(
|
|
83
|
-
if (!Number.isSafeInteger(
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
let n = null,
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
},
|
|
90
|
-
for (const
|
|
91
|
-
if (
|
|
92
|
-
},
|
|
93
|
-
const
|
|
94
|
-
return
|
|
95
|
-
},
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
return
|
|
99
|
-
},
|
|
100
|
-
let
|
|
101
|
-
for (let
|
|
102
|
-
|
|
103
|
-
if (n !== null && n.height >
|
|
104
|
-
},
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
if (!
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
...
|
|
80
|
+
if (!Number.isSafeInteger(c) || c <= 0) throw new RangeError(`[markdown-explorer] the nesting guard's node budget must be a positive safe integer; got ${String(c)}`);
|
|
81
|
+
if (!Number.isSafeInteger(l) || l <= 0) throw new RangeError(`[markdown-explorer] the nesting guard's attribute character budget must be a positive safe integer; got ${String(l)}`);
|
|
82
|
+
if (me(t, P)) return { status: "too-many-attributes" };
|
|
83
|
+
const s = i + G, p = t.length + re;
|
|
84
|
+
let n = null, h = 0, m = 0, d = 0, y = 0;
|
|
85
|
+
const u = (e) => {
|
|
86
|
+
if (m += e, m > c) throw new O("too-many-nodes");
|
|
87
|
+
}, S = (e) => {
|
|
88
|
+
for (const r of e) y += r.name.length + r.value.length;
|
|
89
|
+
if (y > l) throw new O("too-many-attribute-characters");
|
|
90
|
+
}, g = (e, r, o, a) => {
|
|
91
|
+
const H = { node: e, above: null, levels: r, height: 0, keepsChildren: o, attributes: a, first: null, next: null, previous: null }, J = e;
|
|
92
|
+
return J[B] = H, H;
|
|
93
|
+
}, E = (e) => {
|
|
94
|
+
const o = e[B];
|
|
95
|
+
if (o === void 0) throw new Error("[markdown-explorer] the nesting guard was handed a node it did not create");
|
|
96
|
+
return o;
|
|
97
|
+
}, v = (e, r) => {
|
|
98
|
+
let o = r;
|
|
99
|
+
for (let a = e; a !== null && o > a.height; a = a.above)
|
|
100
|
+
a.height = o, o += a.levels;
|
|
101
|
+
if (n !== null && n.height > s) throw new O("too-deep");
|
|
102
|
+
}, x = (e) => {
|
|
103
|
+
const r = e.above;
|
|
104
|
+
r?.keepsChildren && (e.previous === null ? r.first = e.next : e.previous.next = e.next, e.next !== null && (e.next.previous = e.previous)), e.above = null, e.next = null, e.previous = null;
|
|
105
|
+
}, R = (e, r) => {
|
|
106
|
+
if (!w.isElementNode(r)) return;
|
|
107
|
+
const o = E(r), a = E(e);
|
|
108
|
+
x(o), o.above = a, a.keepsChildren && (o.next = a.first, a.first !== null && (a.first.previous = o), a.first = o), r.parentNode = e, v(a, o.height + o.levels);
|
|
109
|
+
}, X = {
|
|
110
|
+
...w,
|
|
113
111
|
createDocument: () => {
|
|
114
|
-
const
|
|
115
|
-
return n = e
|
|
112
|
+
const e = w.createDocument();
|
|
113
|
+
return n = g(e, 0, !1, 0), e;
|
|
116
114
|
},
|
|
117
115
|
createDocumentFragment: () => {
|
|
118
|
-
const
|
|
119
|
-
return e
|
|
116
|
+
const e = w.createDocumentFragment();
|
|
117
|
+
return g(e, 0, !1, 0), e;
|
|
120
118
|
},
|
|
121
|
-
createElement: (
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
return
|
|
119
|
+
createElement: (e, r, o) => {
|
|
120
|
+
if (h += 1, h > p) throw new O("too-many-elements");
|
|
121
|
+
u(1 + o.length), S(o);
|
|
122
|
+
const a = w.createElement(e, r, o);
|
|
123
|
+
return g(a, 1, !(r === ee.NS.HTML && ne.has(e)), o.length), a;
|
|
126
124
|
},
|
|
127
|
-
createCommentNode: (
|
|
128
|
-
if (
|
|
129
|
-
return
|
|
125
|
+
createCommentNode: (e) => {
|
|
126
|
+
if (d += 1, d > te) throw new O("too-many-comments");
|
|
127
|
+
return u(1), w.createCommentNode(e);
|
|
130
128
|
},
|
|
131
|
-
setTemplateContent: (
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
129
|
+
setTemplateContent: (e, r) => {
|
|
130
|
+
w.setTemplateContent(e, r);
|
|
131
|
+
const o = E(r);
|
|
132
|
+
o.above = E(e), v(o.above, o.height);
|
|
135
133
|
},
|
|
136
|
-
appendChild:
|
|
137
|
-
insertBefore: (
|
|
138
|
-
detachNode: (
|
|
139
|
-
|
|
134
|
+
appendChild: R,
|
|
135
|
+
insertBefore: (e, r) => R(e, r),
|
|
136
|
+
detachNode: (e) => {
|
|
137
|
+
w.isElementNode(e) && (x(E(e)), e.parentNode = null);
|
|
140
138
|
},
|
|
141
|
-
getFirstChild: (
|
|
142
|
-
const
|
|
143
|
-
if (!
|
|
144
|
-
return
|
|
139
|
+
getFirstChild: (e) => {
|
|
140
|
+
const r = E(e);
|
|
141
|
+
if (!r.keepsChildren) throw new Error("[markdown-explorer] the nesting guard was asked for the children of a node whose children it does not keep");
|
|
142
|
+
return r.first === null ? null : r.first.node;
|
|
145
143
|
},
|
|
146
144
|
getChildNodes: () => {
|
|
147
145
|
throw new Error("[markdown-explorer] the nesting guard keeps no child lists for source locations");
|
|
148
146
|
},
|
|
149
|
-
onItemPop: (
|
|
150
|
-
const
|
|
151
|
-
|
|
147
|
+
onItemPop: (e) => {
|
|
148
|
+
const r = E(e);
|
|
149
|
+
r.keepsChildren = !1, r.first = null;
|
|
152
150
|
},
|
|
153
151
|
insertText: () => {
|
|
154
152
|
},
|
|
155
153
|
insertTextBefore: () => {
|
|
156
154
|
},
|
|
157
|
-
adoptAttributes: (
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
155
|
+
adoptAttributes: (e, r) => {
|
|
156
|
+
u(r.length), S(r);
|
|
157
|
+
const o = E(e);
|
|
158
|
+
if (o.attributes += r.length, o.attributes > P) throw new O("too-many-attributes");
|
|
161
159
|
}
|
|
162
160
|
};
|
|
163
|
-
let
|
|
161
|
+
let k;
|
|
164
162
|
try {
|
|
165
|
-
|
|
166
|
-
} catch (
|
|
167
|
-
if (
|
|
168
|
-
throw
|
|
163
|
+
k = Z(t, { scriptingEnabled: !1, treeAdapter: X });
|
|
164
|
+
} catch (e) {
|
|
165
|
+
if (e instanceof O) return { status: e.status };
|
|
166
|
+
throw e;
|
|
169
167
|
}
|
|
170
|
-
return { status: "within", depth:
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
img: Object.freeze(["data-asset-src", "data-asset-exists"]),
|
|
181
|
-
section: Object.freeze(["data-footnotes"]),
|
|
182
|
-
iframe: Object.freeze(["allow", "allowfullscreen", "frameborder", "referrerpolicy"])
|
|
183
|
-
}), ze = [.../* @__PURE__ */ new Set([...Object.values(Z).flatMap((r) => r.filter((i) => i.startsWith("data-"))), P])], Be = /* @__PURE__ */ new Set(["src", "href", "xlink:href"]), Pe = /^data:/iu, ve = Object.freeze({
|
|
184
|
-
FORBID_TAGS: Ce,
|
|
185
|
-
FORBID_ATTR: Ie,
|
|
186
|
-
ADD_TAGS: ["iframe"],
|
|
187
|
-
ADD_ATTR: (r, i) => r === P || Z[i]?.includes(r) === !0,
|
|
188
|
-
ADD_URI_SAFE_ATTR: ze,
|
|
189
|
-
ALLOWED_URI_REGEXP: ye,
|
|
190
|
-
ALLOW_DATA_ATTR: !1
|
|
191
|
-
}), Fe = (r) => {
|
|
192
|
-
let i = null;
|
|
193
|
-
for (const u of r.split(";")) {
|
|
194
|
-
const f = u.indexOf(":");
|
|
195
|
-
if (f < 0 || u.slice(0, f).trim().toLowerCase() !== "text-align") continue;
|
|
196
|
-
const l = u.slice(f + 1).trim().toLowerCase();
|
|
197
|
-
De.has(l) && (i = l);
|
|
198
|
-
}
|
|
199
|
-
return i === null ? null : `text-align: ${i}`;
|
|
200
|
-
}, Ge = (r) => r.nodeType === Ue ? { kind: "text", text: r.nodeValue ?? "" } : r.nodeType === He || r.nodeType === xe ? { kind: "ignored" } : r.nodeType === U && r.nodeName.toLowerCase() === "a" ? { kind: "link", href: r.getAttribute("href") } : { kind: "element" }, je = (r) => {
|
|
201
|
-
const i = r.getAttribute("type");
|
|
202
|
-
return i !== null && i.trim().toLowerCase() === "checkbox" && r.hasAttribute("disabled");
|
|
203
|
-
}, Ve = (r, i, u) => {
|
|
204
|
-
if (S.isSupported !== !0) throw new Error("[markdown-explorer] the HTML sanitizer cannot run in this environment");
|
|
205
|
-
if (!Number.isSafeInteger(u) || u <= 0) throw new RangeError(`[markdown-explorer] the HTML sanitizer's depth limit must be a positive integer; got ${String(u)}`);
|
|
206
|
-
const f = Object.freeze([...r]);
|
|
207
|
-
let l = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap();
|
|
208
|
-
const n = (a) => {
|
|
209
|
-
const e = a.parentNode === null ? void 0 : l.get(a.parentNode), o = e === void 0 ? 0 : e + 1;
|
|
210
|
-
if (l.set(a, o), a.nodeType === U && o > u) throw new q(u);
|
|
211
|
-
}, m = (a, e) => {
|
|
212
|
-
if (a.nodeType !== U) return;
|
|
213
|
-
const o = a;
|
|
214
|
-
(e.tagName === "input" && !je(o) || e.tagName === "iframe" && oe(o.getAttribute("src")?.trim(), f) === null) && o.parentNode?.removeChild(o);
|
|
215
|
-
}, g = (a, e) => {
|
|
216
|
-
const o = a.nodeName.toLowerCase();
|
|
217
|
-
if (e.attrName === "style") {
|
|
218
|
-
const E = Fe(e.attrValue);
|
|
219
|
-
E === null ? e.keepAttr = !1 : e.attrValue = E;
|
|
220
|
-
} else if (e.attrName === "allow" && o === "iframe") {
|
|
221
|
-
const E = se(e.attrValue);
|
|
222
|
-
E === null ? e.keepAttr = !1 : e.attrValue = E;
|
|
223
|
-
} else if (e.attrName === "referrerpolicy" && o === "iframe") {
|
|
224
|
-
const E = e.attrValue.trim().toLowerCase();
|
|
225
|
-
ae.has(E) ? e.attrValue = E : e.keepAttr = !1;
|
|
226
|
-
} else e.attrName === H && o === "p" ? T.set(a, a.getAttribute(H)) : Be.has(e.attrName) && Pe.test(e.attrValue) || e.attrName === P && le(e.attrValue) === null ? e.keepAttr = !1 : e.attrName === "id" && Me.has(o) && (e.forceKeepAttr = !0);
|
|
227
|
-
}, h = (a) => {
|
|
228
|
-
const e = a.getAttribute("data-asset-src");
|
|
229
|
-
e !== null && (a.getAttribute("data-asset-exists") !== "false" && ce(e) ? a.setAttribute("src", ue(i, e, null)) : a.removeAttribute("src"));
|
|
230
|
-
}, R = (a) => {
|
|
231
|
-
const e = a.parentNode;
|
|
232
|
-
if (e === null) return;
|
|
233
|
-
const o = T.get(e);
|
|
234
|
-
o != null && ie(o, [...e.childNodes].map(Ge)) !== null && e.setAttribute(H, o);
|
|
235
|
-
}, p = (a) => {
|
|
236
|
-
if (a.nodeType !== U) return;
|
|
237
|
-
const e = a, o = e.nodeName.toLowerCase();
|
|
238
|
-
o === "img" ? h(e) : o === "a" && R(e);
|
|
239
|
-
const E = e.getAttribute("target");
|
|
240
|
-
if (E === null || E.trim().toLowerCase() === "_self") return;
|
|
241
|
-
const y = e.getAttribute("rel"), C = new Set(y === null ? [] : y.split(/\s+/u).filter((x) => x !== ""));
|
|
242
|
-
C.add("noopener"), C.add("noreferrer"), e.setAttribute("rel", [...C].join(" "));
|
|
243
|
-
};
|
|
244
|
-
return (a) => {
|
|
245
|
-
l = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), S.addHook("beforeSanitizeElements", n), S.addHook("uponSanitizeElement", m), S.addHook("uponSanitizeAttribute", g), S.addHook("afterSanitizeAttributes", p);
|
|
246
|
-
try {
|
|
247
|
-
return S.sanitize(a, ve);
|
|
248
|
-
} finally {
|
|
249
|
-
S.removeHook("beforeSanitizeElements", n), S.removeHook("uponSanitizeElement", m), S.removeHook("uponSanitizeAttribute", g), S.removeHook("afterSanitizeAttributes", p);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}, We = (r) => {
|
|
253
|
-
if (r === null || typeof r != "object") return !1;
|
|
254
|
-
const { id: i, input: u } = r;
|
|
255
|
-
if (typeof i != "number" || u === null || typeof u != "object") return !1;
|
|
256
|
-
const { html: f, iframeHosts: l, dataPath: T, maxNodes: n, maxAttributeChars: m, maxSanitizedChars: g } = u;
|
|
257
|
-
return typeof f == "string" && Array.isArray(l) && l.every((h) => typeof h == "string") && typeof T == "string" && T !== "" && [n, m, g].every((h) => Number.isSafeInteger(h) && h > 0);
|
|
258
|
-
}, Qe = () => {
|
|
259
|
-
const r = te;
|
|
260
|
-
if (r === null) throw new Error("[markdown-explorer] the sanitizer worker must run in a worker thread");
|
|
168
|
+
return { status: "within", depth: E(k).height - G, elements: h, nodes: m };
|
|
169
|
+
}, Ae = (t) => {
|
|
170
|
+
if (t === null || typeof t != "object") return !1;
|
|
171
|
+
const { id: i, input: c } = t;
|
|
172
|
+
if (typeof i != "number" || c === null || typeof c != "object") return !1;
|
|
173
|
+
const { html: l, iframeHosts: s, dataPath: p, maxNodes: n, maxAttributeChars: h, maxSanitizedChars: m } = c;
|
|
174
|
+
return typeof l == "string" && Array.isArray(s) && s.every((d) => typeof d == "string") && typeof p == "string" && p !== "" && [n, h, m].every((d) => Number.isSafeInteger(d) && d > 0);
|
|
175
|
+
}, Se = () => {
|
|
176
|
+
const t = W;
|
|
177
|
+
if (t === null) throw new Error("[markdown-explorer] the sanitizer worker must run in a worker thread");
|
|
261
178
|
const i = /* @__PURE__ */ new Map();
|
|
262
|
-
|
|
263
|
-
if (!
|
|
264
|
-
const { id:
|
|
265
|
-
let
|
|
179
|
+
t.on("message", (c) => {
|
|
180
|
+
if (!Ae(c)) throw new TypeError("[markdown-explorer] the sanitizer worker received a message that is not a job");
|
|
181
|
+
const { id: l, input: s } = c;
|
|
182
|
+
let p;
|
|
266
183
|
try {
|
|
267
|
-
if (
|
|
268
|
-
|
|
184
|
+
if (Te(s.html, D, s.maxNodes, s.maxAttributeChars).status !== "within") {
|
|
185
|
+
t.postMessage({ id: l, output: { status: "too-large" } });
|
|
269
186
|
return;
|
|
270
187
|
}
|
|
271
|
-
const n = JSON.stringify([
|
|
272
|
-
let
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
|
|
188
|
+
const n = JSON.stringify([s.iframeHosts, s.dataPath]);
|
|
189
|
+
let h = i.get(n);
|
|
190
|
+
h === void 0 && (h = K(q, s.iframeHosts, s.dataPath, D), i.set(n, h));
|
|
191
|
+
const m = h(s.html);
|
|
192
|
+
p = m.length > s.maxSanitizedChars ? { status: "too-large" } : { status: "sanitized", html: m };
|
|
276
193
|
} catch (n) {
|
|
277
|
-
|
|
194
|
+
p = n instanceof Y ? { status: "too-large" } : { status: "error", message: n instanceof Error ? `${n.name}: ${n.message}` : String(n) };
|
|
278
195
|
}
|
|
279
|
-
|
|
280
|
-
}),
|
|
196
|
+
t.postMessage({ id: l, output: p });
|
|
197
|
+
}), t.postMessage({ ready: !0 });
|
|
281
198
|
};
|
|
282
|
-
|
|
199
|
+
Se();
|