@mulmoclaude/core 5.11.3 → 5.12.0
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/assets/helps/error-recovery.md +19 -7
- package/assets/helps/sandbox.md +2 -2
- package/assets/helps/spreadsheet.md +9 -1
- package/dist/collection/index.cjs +3 -3
- package/dist/collection/index.js +3 -3
- package/dist/collection/registry/server/index.cjs +3 -3
- package/dist/collection/registry/server/index.js +3 -3
- package/dist/collection/server/index.cjs +2 -2
- package/dist/collection/server/index.js +2 -2
- package/dist/collection-watchers/index.cjs +4 -4
- package/dist/collection-watchers/index.js +4 -4
- package/dist/{discovery-CbwHtcwk.js → discovery-BTl21_hI.js} +3 -3
- package/dist/{discovery-CbwHtcwk.js.map → discovery-BTl21_hI.js.map} +1 -1
- package/dist/{discovery-DgZRmO7F.cjs → discovery-DBJRuDv2.cjs} +3 -3
- package/dist/{discovery-DgZRmO7F.cjs.map → discovery-DBJRuDv2.cjs.map} +1 -1
- package/dist/{dist-MFUV9FYo.js → dist-C0oU4X3A.js} +2 -2
- package/dist/dist-C0oU4X3A.js.map +1 -0
- package/dist/{dist-BZ62pKuU.cjs → dist-CAc42oZn.cjs} +2 -2
- package/dist/dist-CAc42oZn.cjs.map +1 -0
- package/dist/errorMessage-BYNQlnx0.cjs +1 -0
- package/dist/errorMessage-DVcsvx02.js +1 -0
- package/dist/{errors-B0xloJ3E.cjs → errors-DQr4mDbJ.cjs} +2 -2
- package/dist/{errors-B0xloJ3E.cjs.map → errors-DQr4mDbJ.cjs.map} +1 -1
- package/dist/{errors-zTAsW7dS.js → errors-Dgiw-unK.js} +2 -2
- package/dist/{errors-zTAsW7dS.js.map → errors-Dgiw-unK.js.map} +1 -1
- package/dist/feeds/server/index.cjs +5 -5
- package/dist/feeds/server/index.cjs.map +1 -1
- package/dist/feeds/server/index.js +5 -5
- package/dist/feeds/server/index.js.map +1 -1
- package/dist/google/index.cjs +3 -3
- package/dist/google/index.js +3 -3
- package/dist/{listen-N_8XdKz_.cjs → listen-CUJyj9V2.cjs} +2 -2
- package/dist/{listen-N_8XdKz_.cjs.map → listen-CUJyj9V2.cjs.map} +1 -1
- package/dist/{listen-DUlzSOzX.js → listen-CnLfYFdW.js} +2 -2
- package/dist/{listen-DUlzSOzX.js.map → listen-CnLfYFdW.js.map} +1 -1
- package/dist/notifier/index.cjs +1 -1
- package/dist/notifier/index.js +1 -1
- package/dist/{notifier-CiemUClt.cjs → notifier-BF49QNV7.cjs} +2 -2
- package/dist/{notifier-CiemUClt.cjs.map → notifier-BF49QNV7.cjs.map} +1 -1
- package/dist/{notifier-dgkC-h80.js → notifier-XGAgdX2J.js} +2 -2
- package/dist/{notifier-dgkC-h80.js.map → notifier-XGAgdX2J.js.map} +1 -1
- package/dist/plugin-vue/index.cjs +273 -197
- package/dist/plugin-vue/index.cjs.map +1 -1
- package/dist/plugin-vue/index.js +273 -197
- package/dist/plugin-vue/index.js.map +1 -1
- package/dist/prompt-files/index.cjs +1 -1
- package/dist/prompt-files/index.js +1 -1
- package/dist/{promptSafety-DFaOnOWN.js → promptSafety-C9uabl9i.js} +2 -2
- package/dist/{promptSafety-DFaOnOWN.js.map → promptSafety-C9uabl9i.js.map} +1 -1
- package/dist/{promptSafety-yET9jLep.cjs → promptSafety-CKmqbSTK.cjs} +2 -2
- package/dist/{promptSafety-yET9jLep.cjs.map → promptSafety-CKmqbSTK.cjs.map} +1 -1
- package/dist/remote-host/index.cjs +1 -1
- package/dist/remote-host/index.d.ts +7 -1
- package/dist/remote-host/index.js +1 -1
- package/dist/remote-host/server/hostRunner.d.ts +2 -1
- package/dist/remote-host/server/index.cjs +33 -28
- package/dist/remote-host/server/index.cjs.map +1 -1
- package/dist/remote-host/server/index.d.ts +2 -1
- package/dist/remote-host/server/index.js +33 -28
- package/dist/remote-host/server/index.js.map +1 -1
- package/dist/remote-host/server/lifecycle.d.ts +2 -0
- package/dist/remote-host/server/presenceProbe.d.ts +0 -2
- package/dist/remote-host/server/withTimeout.d.ts +2 -0
- package/dist/{remote-host-CoNX9JEC.js → remote-host-5f5LOmDU.js} +8 -4
- package/dist/remote-host-5f5LOmDU.js.map +1 -0
- package/dist/{remote-host-BMjh_F-6.cjs → remote-host-BLWjSIZd.cjs} +8 -4
- package/dist/remote-host-BLWjSIZd.cjs.map +1 -0
- package/dist/remote-view/index.cjs +1 -1
- package/dist/remote-view/index.js +1 -1
- package/dist/scheduler/index.cjs +2 -2
- package/dist/scheduler/index.js +2 -2
- package/dist/{server-BtbbQqBY.js → server-BdRkw2Gh.js} +5 -5
- package/dist/{server-BtbbQqBY.js.map → server-BdRkw2Gh.js.map} +1 -1
- package/dist/{server-CJek9Y3Q.cjs → server-ekmEXF9t.cjs} +5 -5
- package/dist/{server-CJek9Y3Q.cjs.map → server-ekmEXF9t.cjs.map} +1 -1
- package/dist/utils/index.cjs +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/whisper/index.cjs +2 -2
- package/dist/whisper/index.js +2 -2
- package/dist/wiki/index.cjs +1 -1
- package/dist/wiki/index.js +1 -1
- package/dist/workspace-setup/index.js +1 -1
- package/dist/workspace-setup/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/dist-BZ62pKuU.cjs.map +0 -1
- package/dist/dist-MFUV9FYo.js.map +0 -1
- package/dist/errorMessage-OEQzRwsi.cjs +0 -1
- package/dist/errorMessage-VEiXHRnX.js +0 -1
- package/dist/remote-host-BMjh_F-6.cjs.map +0 -1
- package/dist/remote-host-CoNX9JEC.js.map +0 -1
|
@@ -137,8 +137,8 @@ IconGlyph.props = {
|
|
|
137
137
|
fontClass: String
|
|
138
138
|
};
|
|
139
139
|
//#endregion
|
|
140
|
-
//#region
|
|
141
|
-
/*! @license DOMPurify 3.4.
|
|
140
|
+
//#region ../../../../mulmoclaude/node_modules/dompurify/dist/purify.es.mjs
|
|
141
|
+
/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */
|
|
142
142
|
function _OverloadYield(e, d) {
|
|
143
143
|
this.v = e, this.k = d;
|
|
144
144
|
}
|
|
@@ -262,9 +262,12 @@ Array.prototype.indexOf;
|
|
|
262
262
|
var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
263
263
|
var arrayPop = unapply(Array.prototype.pop);
|
|
264
264
|
var arrayPush = unapply(Array.prototype.push);
|
|
265
|
-
Array.prototype.slice;
|
|
265
|
+
var arraySlice = unapply(Array.prototype.slice);
|
|
266
266
|
var arraySplice = unapply(Array.prototype.splice);
|
|
267
267
|
var arrayIsArray = Array.isArray;
|
|
268
|
+
var setCreate = unconstruct(Set);
|
|
269
|
+
var setAdd = unapply(Set.prototype.add);
|
|
270
|
+
var setHas = unapply(Set.prototype.has);
|
|
268
271
|
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
269
272
|
var stringToString = unapply(String.prototype.toString);
|
|
270
273
|
var stringMatch = unapply(String.prototype.match);
|
|
@@ -409,6 +412,25 @@ function lookupGetter(object, prop) {
|
|
|
409
412
|
}
|
|
410
413
|
return fallbackValue;
|
|
411
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* Like lookupGetter, but for accessor properties only, and returns null
|
|
417
|
+
* instead of a null-returning fallback when no getter exists on the chain.
|
|
418
|
+
* Lets a caller fall back to a direct property read in environments that
|
|
419
|
+
* lack the getter, where a fallback returning null would be indistinguishable
|
|
420
|
+
* from a legitimate null value (e.g. namespaceURI of a no-namespace element).
|
|
421
|
+
*
|
|
422
|
+
* @param object - The object (usually a prototype) to start the lookup at.
|
|
423
|
+
* @param prop - The accessor property name.
|
|
424
|
+
* @returns The unapplied getter, or null if none was found.
|
|
425
|
+
*/
|
|
426
|
+
function lookupAccessor(object, prop) {
|
|
427
|
+
while (object !== null) {
|
|
428
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
429
|
+
if (desc) return desc.get ? unapply(desc.get) : null;
|
|
430
|
+
object = getPrototypeOf(object);
|
|
431
|
+
}
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
412
434
|
function isRegex(value) {
|
|
413
435
|
try {
|
|
414
436
|
regExpTest(value, "");
|
|
@@ -1093,7 +1115,7 @@ var NODE_TYPE = {
|
|
|
1093
1115
|
documentFragment: 11,
|
|
1094
1116
|
notation: 12
|
|
1095
1117
|
};
|
|
1096
|
-
var
|
|
1118
|
+
var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, [
|
|
1097
1119
|
"style",
|
|
1098
1120
|
"script",
|
|
1099
1121
|
"xmp",
|
|
@@ -1102,15 +1124,7 @@ var LITERAL_TEXT_ELEMENT_NAMES = [
|
|
|
1102
1124
|
"noframes",
|
|
1103
1125
|
"plaintext",
|
|
1104
1126
|
"noscript"
|
|
1105
|
-
];
|
|
1106
|
-
var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, LITERAL_TEXT_ELEMENT_NAMES));
|
|
1107
|
-
var LITERAL_TEXT_CLOSE = function() {
|
|
1108
|
-
const map = {};
|
|
1109
|
-
arrayForEach(LITERAL_TEXT_ELEMENT_NAMES, (name) => {
|
|
1110
|
-
map[name] = seal(new RegExp("</" + name + "(?=[\\t\\n\\f\\r />])", "i"));
|
|
1111
|
-
});
|
|
1112
|
-
return freeze(map);
|
|
1113
|
-
}();
|
|
1127
|
+
]));
|
|
1114
1128
|
var getGlobal = function getGlobal() {
|
|
1115
1129
|
return typeof window === "undefined" ? null : window;
|
|
1116
1130
|
};
|
|
@@ -1188,7 +1202,7 @@ var _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback)
|
|
|
1188
1202
|
function createDOMPurify() {
|
|
1189
1203
|
let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
|
1190
1204
|
const DOMPurify = (root) => createDOMPurify(root);
|
|
1191
|
-
DOMPurify.version = "3.4.
|
|
1205
|
+
DOMPurify.version = "3.4.17";
|
|
1192
1206
|
DOMPurify.removed = [];
|
|
1193
1207
|
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
1194
1208
|
DOMPurify.isSupported = false;
|
|
@@ -1220,6 +1234,10 @@ function createDOMPurify() {
|
|
|
1220
1234
|
const _readNodeName = function _readNodeName(node) {
|
|
1221
1235
|
return getNodeName ? getNodeName(node) : node.nodeName;
|
|
1222
1236
|
};
|
|
1237
|
+
const getNamespaceURI = lookupAccessor(ElementPrototype, "namespaceURI");
|
|
1238
|
+
const _readNamespaceURI = function _readNamespaceURI(element) {
|
|
1239
|
+
return getNamespaceURI ? getNamespaceURI(element) : element.namespaceURI;
|
|
1240
|
+
};
|
|
1223
1241
|
if (typeof HTMLTemplateElement === "function") {
|
|
1224
1242
|
const template = document.createElement("template");
|
|
1225
1243
|
if (template.content && template.content.ownerDocument) document = template.content.ownerDocument;
|
|
@@ -1340,6 +1358,7 @@ function createDOMPurify() {
|
|
|
1340
1358
|
const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
|
|
1341
1359
|
let KEEP_CONTENT = true;
|
|
1342
1360
|
let IN_PLACE = false;
|
|
1361
|
+
let IN_PLACE_VISITED = null;
|
|
1343
1362
|
let USE_PROFILES = {};
|
|
1344
1363
|
let FORBID_CONTENTS = null;
|
|
1345
1364
|
const DEFAULT_FORBID_CONTENTS = addToSet({}, [
|
|
@@ -1613,18 +1632,23 @@ function createDOMPurify() {
|
|
|
1613
1632
|
* return. Return true otherwise.
|
|
1614
1633
|
*/
|
|
1615
1634
|
const _checkValidNamespace = function _checkValidNamespace(element) {
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1635
|
+
const elementNamespace = _readNamespaceURI(element);
|
|
1636
|
+
const tagName = stringToLowerCase(_readNodeName(element));
|
|
1637
|
+
const parentNode = getParentNode(element);
|
|
1638
|
+
let parent;
|
|
1639
|
+
let parentTagName;
|
|
1640
|
+
if (parentNode && _readNodeType(parentNode) === NODE_TYPE.element) {
|
|
1641
|
+
parent = { namespaceURI: _readNamespaceURI(parentNode) };
|
|
1642
|
+
parentTagName = stringToLowerCase(_readNodeName(parentNode));
|
|
1643
|
+
} else {
|
|
1644
|
+
parent = { namespaceURI: NAMESPACE };
|
|
1645
|
+
parentTagName = "template";
|
|
1646
|
+
}
|
|
1647
|
+
if (!ALLOWED_NAMESPACES[elementNamespace]) return false;
|
|
1648
|
+
if (elementNamespace === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
1649
|
+
if (elementNamespace === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
1650
|
+
if (elementNamespace === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
1651
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[elementNamespace]) return true;
|
|
1628
1652
|
return false;
|
|
1629
1653
|
};
|
|
1630
1654
|
/**
|
|
@@ -1668,36 +1692,21 @@ function createDOMPurify() {
|
|
|
1668
1692
|
}
|
|
1669
1693
|
};
|
|
1670
1694
|
/**
|
|
1671
|
-
*
|
|
1672
|
-
*
|
|
1673
|
-
*
|
|
1674
|
-
* (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
|
|
1675
|
-
* custom element's reaction detaches a node so `_forceRemove`'s deliberate
|
|
1676
|
-
* parentless guard throws, or any other re-entrant engine mutation — would
|
|
1677
|
-
* otherwise leave the caller's *live* tree half-sanitized, with everything
|
|
1678
|
-
* after the abort point still carrying its handlers. There is no safe way
|
|
1679
|
-
* to resume the walk (the tree mutated under us), so we strip the root bare:
|
|
1680
|
-
* remove every child and every attribute, then let the caller's catch see
|
|
1681
|
-
* the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
|
|
1682
|
-
* getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
|
|
1695
|
+
* Fail-closed teardown of an in-place root: strip every disallowed attribute
|
|
1696
|
+
* in the subtree first, so nothing armed is left behind, then remove all
|
|
1697
|
+
* children and the root's own attributes.
|
|
1683
1698
|
*
|
|
1684
1699
|
* @param root the in-place root to empty
|
|
1685
1700
|
*/
|
|
1686
1701
|
const _neutralizeRoot = function _neutralizeRoot(root) {
|
|
1687
1702
|
_neutralizeSubtree(root);
|
|
1688
1703
|
const childNodes = getChildNodes(root);
|
|
1689
|
-
if (childNodes) {
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
try {
|
|
1696
|
-
remove(child);
|
|
1697
|
-
} catch (_) {}
|
|
1698
|
-
});
|
|
1699
|
-
}
|
|
1700
|
-
const attributes = getAttributes(root);
|
|
1704
|
+
if (childNodes) arrayForEach(arraySlice(childNodes), (child) => {
|
|
1705
|
+
try {
|
|
1706
|
+
remove(child);
|
|
1707
|
+
} catch (_) {}
|
|
1708
|
+
});
|
|
1709
|
+
const attributes = _readNodeType(root) === NODE_TYPE.element ? getAttributes(root) : null;
|
|
1701
1710
|
if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
|
|
1702
1711
|
const attribute = attributes[i];
|
|
1703
1712
|
const name = attribute && attribute.name;
|
|
@@ -1705,18 +1714,9 @@ function createDOMPurify() {
|
|
|
1705
1714
|
}
|
|
1706
1715
|
};
|
|
1707
1716
|
/**
|
|
1708
|
-
*
|
|
1709
|
-
*
|
|
1710
|
-
*
|
|
1711
|
-
* lookup key for HTML elements in an HTML document, so they silently miss an
|
|
1712
|
-
* attribute whose stored qualified name still contains uppercase ASCII
|
|
1713
|
-
* letters. That happens when the node came from a case-preserving source
|
|
1714
|
-
* (an XML/XHTML document imported via importNode(), or createAttributeNS()),
|
|
1715
|
-
* where e.g. `ONERROR` survives the walk: the policy check lowercases to
|
|
1716
|
-
* `onerror` and rejects it, but `removeAttribute('ONERROR')` looks up
|
|
1717
|
-
* `onerror` and finds nothing. Remove the exact Attr node instead, which is
|
|
1718
|
-
* case- and namespace-exact, and fall back to name-based removal only when
|
|
1719
|
-
* the caller could not supply the node.
|
|
1717
|
+
* Removes an attribute, preferably as its exact Attr node: name-based
|
|
1718
|
+
* removal lowercases the name in HTML documents and misses case-preserved
|
|
1719
|
+
* names, e.g. from imported XHTML.
|
|
1720
1720
|
*
|
|
1721
1721
|
* @param name an Attribute name
|
|
1722
1722
|
* @param element a DOM node
|
|
@@ -1750,12 +1750,8 @@ function createDOMPurify() {
|
|
|
1750
1750
|
}
|
|
1751
1751
|
};
|
|
1752
1752
|
/**
|
|
1753
|
-
*
|
|
1754
|
-
*
|
|
1755
|
-
* Removes every attribute the active configuration does not allow from a
|
|
1756
|
-
* single element, using the same allowlist as the main attribute pass (so
|
|
1757
|
-
* `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
|
|
1758
|
-
* neutralise nodes that are being discarded from an in-place tree.
|
|
1753
|
+
* Removes every attribute the configuration does not allow. Used to
|
|
1754
|
+
* neutralize nodes discarded from an in-place tree.
|
|
1759
1755
|
*
|
|
1760
1756
|
* @param element the element to strip
|
|
1761
1757
|
*/
|
|
@@ -1770,77 +1766,158 @@ function createDOMPurify() {
|
|
|
1770
1766
|
}
|
|
1771
1767
|
};
|
|
1772
1768
|
/**
|
|
1773
|
-
*
|
|
1774
|
-
*
|
|
1775
|
-
*
|
|
1776
|
-
*
|
|
1777
|
-
* namespace, comment, processing-instruction and KEEP_CONTENT:false removals
|
|
1778
|
-
* all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
|
|
1779
|
-
* those dropped nodes are detached from the caller's LIVE tree but a
|
|
1780
|
-
* handler-bearing original among them (an `<img onerror>`/`<video>` that was
|
|
1781
|
-
* loading) keeps its queued resource event, which fires in page scope after
|
|
1782
|
-
* sanitize returns. This walks a removed subtree and strips every attribute
|
|
1783
|
-
* the active configuration does not allow — so `on*` handlers are cancelled
|
|
1784
|
-
* through the SAME allowlist that governs kept nodes, not a separate `/^on/`
|
|
1785
|
-
* blocklist. Run synchronously before sanitize returns, i.e. before any
|
|
1786
|
-
* queued event can fire. Hook-free by design: these nodes leave the output,
|
|
1787
|
-
* so firing attribute hooks for them would be surprising. Clobber-safe reads;
|
|
1788
|
-
* a doomed clobbered node may shadow `removeAttribute` (its own attributes are
|
|
1789
|
-
* irrelevant — it is discarded — while its non-clobbered descendants, e.g.
|
|
1790
|
-
* the `<img>`, are reached and scrubbed).
|
|
1769
|
+
* Iterative depth-first walk, so deep trees cannot overflow the call stack,
|
|
1770
|
+
* reading through the cached getters, so clobbering cannot hide children.
|
|
1771
|
+
* When `visit` returns false, the node's children are skipped. With
|
|
1772
|
+
* `intoShadow`, open shadow roots are walked after their host's children.
|
|
1791
1773
|
*
|
|
1792
|
-
* @param root
|
|
1774
|
+
* @param root where to start
|
|
1775
|
+
* @param visit called for every node
|
|
1776
|
+
* @param intoShadow whether to enter open shadow roots
|
|
1793
1777
|
*/
|
|
1794
|
-
const
|
|
1778
|
+
const _walkTree = function _walkTree(root, visit) {
|
|
1779
|
+
let intoShadow = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
1795
1780
|
const stack = [root];
|
|
1796
1781
|
while (stack.length > 0) {
|
|
1797
1782
|
const node = stack.pop();
|
|
1798
|
-
if (
|
|
1783
|
+
if (visit(node) === false) continue;
|
|
1784
|
+
if (intoShadow && _readNodeType(node) === NODE_TYPE.element) {
|
|
1785
|
+
const shadowRoot = getShadowRoot(node);
|
|
1786
|
+
if (_isDocumentFragment(shadowRoot)) stack.push(shadowRoot);
|
|
1787
|
+
}
|
|
1799
1788
|
const childNodes = getChildNodes(node);
|
|
1800
1789
|
if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
|
|
1801
1790
|
}
|
|
1802
1791
|
};
|
|
1803
1792
|
/**
|
|
1804
|
-
*
|
|
1793
|
+
* Strips disallowed attributes from every element of a discarded subtree,
|
|
1794
|
+
* so a handler that is already queued (a loading image) cannot fire.
|
|
1805
1795
|
*
|
|
1806
|
-
*
|
|
1807
|
-
|
|
1796
|
+
* @param root the root of a removed subtree
|
|
1797
|
+
*/
|
|
1798
|
+
const _neutralizeSubtree = function _neutralizeSubtree(root) {
|
|
1799
|
+
_walkTree(root, (node) => {
|
|
1800
|
+
if (_readNodeType(node) === NODE_TYPE.element) _stripDisallowedAttributes(node);
|
|
1801
|
+
});
|
|
1802
|
+
};
|
|
1803
|
+
/**
|
|
1804
|
+
* All nodes under `root`, root first, including open shadow roots. Template
|
|
1805
|
+
* content is not entered, it is inert.
|
|
1806
|
+
*
|
|
1807
|
+
* @param root the in-place root
|
|
1808
|
+
* @return the nodes
|
|
1809
|
+
*/
|
|
1810
|
+
const _collectLiveNodes = function _collectLiveNodes(root) {
|
|
1811
|
+
const nodes = [];
|
|
1812
|
+
_walkTree(root, (node) => {
|
|
1813
|
+
nodes.push(node);
|
|
1814
|
+
}, true);
|
|
1815
|
+
return nodes;
|
|
1816
|
+
};
|
|
1817
|
+
/**
|
|
1818
|
+
* Strips disallowed attributes from every element that was under the
|
|
1819
|
+
* in-place root when the call started and no longer is, whatever removed
|
|
1820
|
+
* or moved it.
|
|
1808
1821
|
*
|
|
1809
|
-
*
|
|
1810
|
-
*
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1822
|
+
* @param root the in-place root
|
|
1823
|
+
* @param before the root's nodes, collected before the walk
|
|
1824
|
+
*/
|
|
1825
|
+
const _neutralizeEscapedElements = function _neutralizeEscapedElements(root, before) {
|
|
1826
|
+
const reachable = setCreate();
|
|
1827
|
+
arrayForEach(_collectLiveNodes(root), (node) => {
|
|
1828
|
+
if (_readNodeType(node) === NODE_TYPE.element) setAdd(reachable, node);
|
|
1829
|
+
});
|
|
1830
|
+
arrayForEach(before, (node) => {
|
|
1831
|
+
if (_readNodeType(node) === NODE_TYPE.element && !setHas(reachable, node)) _stripDisallowedAttributes(node);
|
|
1832
|
+
});
|
|
1833
|
+
};
|
|
1834
|
+
/**
|
|
1835
|
+
* Neutralizes everything that left the in-place tree during the call: what
|
|
1836
|
+
* DOMPurify removed, and what hooks or custom elements removed or moved out.
|
|
1819
1837
|
*
|
|
1820
|
-
*
|
|
1821
|
-
*
|
|
1822
|
-
*
|
|
1823
|
-
|
|
1824
|
-
|
|
1838
|
+
* @param root the in-place root
|
|
1839
|
+
* @param before the root's nodes, collected before the walk
|
|
1840
|
+
* @return true if the root itself was removed
|
|
1841
|
+
*/
|
|
1842
|
+
const _neutralizeDiscarded = function _neutralizeDiscarded(root, before) {
|
|
1843
|
+
let rootRemoved = false;
|
|
1844
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
1845
|
+
if (entry.element) {
|
|
1846
|
+
rootRemoved = rootRemoved || entry.element === root;
|
|
1847
|
+
_neutralizeSubtree(entry.element);
|
|
1848
|
+
}
|
|
1849
|
+
});
|
|
1850
|
+
_neutralizeEscapedElements(root, before);
|
|
1851
|
+
return rootRemoved;
|
|
1852
|
+
};
|
|
1853
|
+
const MAX_UNVISITED_ROUNDS = 8;
|
|
1854
|
+
/**
|
|
1855
|
+
* The walk only moves forward, so a node moved to a position it already
|
|
1856
|
+
* passed is never visited. Give every original node that is still in the
|
|
1857
|
+
* tree but unvisited the normal treatment, hooks included. Nodes created
|
|
1858
|
+
* during the call are left alone. Fails closed if the tree keeps changing.
|
|
1825
1859
|
*
|
|
1826
|
-
*
|
|
1827
|
-
*
|
|
1860
|
+
* @param root the in-place root
|
|
1861
|
+
* @param before the root's nodes, collected before the walk
|
|
1862
|
+
*/
|
|
1863
|
+
const _sanitizeUnvisitedNodes = function _sanitizeUnvisitedNodes(root, before) {
|
|
1864
|
+
const visited = IN_PLACE_VISITED;
|
|
1865
|
+
let original = null;
|
|
1866
|
+
const getOriginal = () => {
|
|
1867
|
+
if (!original) {
|
|
1868
|
+
original = setCreate();
|
|
1869
|
+
arrayForEach(before, (beforeNode) => {
|
|
1870
|
+
setAdd(original, beforeNode);
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
return original;
|
|
1874
|
+
};
|
|
1875
|
+
for (let round = 0;; round++) {
|
|
1876
|
+
const live = _collectLiveNodes(root);
|
|
1877
|
+
const containers = [root];
|
|
1878
|
+
let pending = false;
|
|
1879
|
+
arrayForEach(live, (node) => {
|
|
1880
|
+
if (_readNodeType(node) === NODE_TYPE.documentFragment) arrayPush(containers, node);
|
|
1881
|
+
else if (!pending && !setHas(visited, node)) pending = setHas(getOriginal(), node);
|
|
1882
|
+
});
|
|
1883
|
+
if (!pending) return;
|
|
1884
|
+
if (round >= MAX_UNVISITED_ROUNDS) throw typeErrorCreate("the tree kept changing during in-place sanitization; refusing to return it");
|
|
1885
|
+
arrayForEach(containers, (container, index) => {
|
|
1886
|
+
_sanitizeUnvisitedIn(container, index > 0, root, getOriginal());
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
};
|
|
1890
|
+
/**
|
|
1891
|
+
* One _sanitizeUnvisitedNodes pass over the root or an open shadow root.
|
|
1828
1892
|
*
|
|
1829
|
-
*
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1832
|
-
*
|
|
1833
|
-
|
|
1834
|
-
|
|
1893
|
+
* @param container the root or an open shadow root
|
|
1894
|
+
* @param inShadow whether container is a shadow root
|
|
1895
|
+
* @param root the in-place root
|
|
1896
|
+
* @param original the root's nodes collected before the walk, as a set
|
|
1897
|
+
*/
|
|
1898
|
+
const _sanitizeUnvisitedIn = function _sanitizeUnvisitedIn(container, inShadow, root, original) {
|
|
1899
|
+
const iterator = _createNodeIterator(container);
|
|
1900
|
+
let node;
|
|
1901
|
+
while (node = iterator.nextNode()) {
|
|
1902
|
+
if (!setHas(original, node) || setHas(IN_PLACE_VISITED, node)) continue;
|
|
1903
|
+
if (inShadow) _executeHooks(hooks.uponSanitizeShadowNode, node, null);
|
|
1904
|
+
_sanitizeElements(node, root);
|
|
1905
|
+
_sanitizeAttributes(node, root);
|
|
1906
|
+
if (_isDocumentFragment(node.content)) _sanitizeShadowDOM2(node.content);
|
|
1907
|
+
}
|
|
1908
|
+
};
|
|
1909
|
+
/**
|
|
1910
|
+
* Records that _sanitizeElements processed `node`. No-op outside IN_PLACE.
|
|
1835
1911
|
*
|
|
1836
|
-
* @param
|
|
1912
|
+
* @param node the node being processed
|
|
1837
1913
|
*/
|
|
1914
|
+
const _markVisited = function _markVisited(node) {
|
|
1915
|
+
if (IN_PLACE_VISITED) setAdd(IN_PLACE_VISITED, node);
|
|
1916
|
+
};
|
|
1838
1917
|
/**
|
|
1839
|
-
*
|
|
1840
|
-
*
|
|
1841
|
-
*
|
|
1842
|
-
* everywhere except on <label>/<output>, and the whole policy is gated on
|
|
1843
|
-
* SAFE_FOR_XML (see the rationale block in _isValidAttribute).
|
|
1918
|
+
* Patch-linkage attributes (declarative partial updates): `patchsrc`
|
|
1919
|
+
* always, `for` everywhere except on <label> and <output>. Gated on
|
|
1920
|
+
* SAFE_FOR_XML. Shared by the IN_PLACE pre-pass and _isValidAttribute.
|
|
1844
1921
|
*
|
|
1845
1922
|
* @param lcName the transformCaseFunc'd attribute name
|
|
1846
1923
|
* @param lcTag the transformCaseFunc'd tag name of the carrying element
|
|
@@ -1851,17 +1928,26 @@ function createDOMPurify() {
|
|
|
1851
1928
|
if (lcName === "patchsrc") return true;
|
|
1852
1929
|
return lcName === "for" && lcTag !== "label" && lcTag !== "output";
|
|
1853
1930
|
};
|
|
1931
|
+
/**
|
|
1932
|
+
* IN_PLACE pre-pass: sever all patch linkage before the walk, so no patch
|
|
1933
|
+
* can fire mid-walk into a part of the tree the walker already passed.
|
|
1934
|
+
* Removes range markers (processing instructions, comments with markup)
|
|
1935
|
+
* and strips linkage attributes. It cannot undo a patch that already fired.
|
|
1936
|
+
*
|
|
1937
|
+
* TODO: if the shipped feature can patch through `for` on <label>/<output>,
|
|
1938
|
+
* drop that pair here too (see test/declarative-patch-probe.html).
|
|
1939
|
+
*
|
|
1940
|
+
* @param root the in-place root to sweep
|
|
1941
|
+
*/
|
|
1854
1942
|
const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
|
|
1855
1943
|
if (!SAFE_FOR_XML) return;
|
|
1856
|
-
|
|
1857
|
-
while (stack.length > 0) {
|
|
1858
|
-
const node = stack.pop();
|
|
1944
|
+
_walkTree(root, (node) => {
|
|
1859
1945
|
const nodeType = _readNodeType(node);
|
|
1860
1946
|
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
1861
1947
|
try {
|
|
1862
1948
|
remove(node);
|
|
1863
1949
|
} catch (_) {}
|
|
1864
|
-
|
|
1950
|
+
return false;
|
|
1865
1951
|
}
|
|
1866
1952
|
if (nodeType === NODE_TYPE.element) {
|
|
1867
1953
|
const element = node;
|
|
@@ -1871,9 +1957,8 @@ function createDOMPurify() {
|
|
|
1871
1957
|
if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) element.removeAttribute("for");
|
|
1872
1958
|
} catch (_) {}
|
|
1873
1959
|
}
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
}
|
|
1960
|
+
return true;
|
|
1961
|
+
});
|
|
1877
1962
|
};
|
|
1878
1963
|
/**
|
|
1879
1964
|
* _initDocument
|
|
@@ -1950,6 +2035,27 @@ function createDOMPurify() {
|
|
|
1950
2035
|
*/
|
|
1951
2036
|
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
1952
2037
|
var _node$querySelectorAl;
|
|
2038
|
+
_scrubOwnCharacterData(node);
|
|
2039
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
|
|
2040
|
+
if (templates) arrayForEach(templates, (tmpl) => {
|
|
2041
|
+
if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
|
|
2042
|
+
});
|
|
2043
|
+
};
|
|
2044
|
+
/**
|
|
2045
|
+
* _scrubOwnCharacterData
|
|
2046
|
+
*
|
|
2047
|
+
* Non-recursive core of _scrubTemplateExpressions: normalize `node` and
|
|
2048
|
+
* strip template expressions from its own character data only. Does not
|
|
2049
|
+
* enter <template>.content or attached shadow roots (NodeIterator never
|
|
2050
|
+
* does). Used by _sanitizeShadowDOM, where every nested template content
|
|
2051
|
+
* and shadow root is already walked - and therefore scrubbed - by its own
|
|
2052
|
+
* recursive _sanitizeShadowDOM call; recursing here as well would rescrub
|
|
2053
|
+
* each nested fragment once per ancestor, which is quadratic in nesting
|
|
2054
|
+
* depth.
|
|
2055
|
+
*
|
|
2056
|
+
* @param node The root whose own character data should be scrubbed.
|
|
2057
|
+
*/
|
|
2058
|
+
const _scrubOwnCharacterData = function _scrubOwnCharacterData(node) {
|
|
1953
2059
|
node.normalize();
|
|
1954
2060
|
const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
|
|
1955
2061
|
const walker = createNodeIterator.call(doc || node, node, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
|
|
@@ -1958,10 +2064,6 @@ function createDOMPurify() {
|
|
|
1958
2064
|
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
1959
2065
|
currentNode = walker.nextNode();
|
|
1960
2066
|
}
|
|
1961
|
-
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
|
|
1962
|
-
if (templates) arrayForEach(templates, (tmpl) => {
|
|
1963
|
-
if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
|
|
1964
|
-
});
|
|
1965
2067
|
};
|
|
1966
2068
|
/**
|
|
1967
2069
|
* _isClobbered
|
|
@@ -2037,7 +2139,7 @@ function createDOMPurify() {
|
|
|
2037
2139
|
*/
|
|
2038
2140
|
const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
|
|
2039
2141
|
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
|
|
2040
|
-
if (SAFE_FOR_XML && currentNode
|
|
2142
|
+
if (SAFE_FOR_XML && LITERAL_TEXT_ELEMENTS[tagName] && _readNodeType(currentNode) === NODE_TYPE.element && _readNamespaceURI(currentNode) === HTML_NAMESPACE && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent))) return true;
|
|
2041
2143
|
if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
|
|
2042
2144
|
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
|
|
2043
2145
|
return false;
|
|
@@ -2081,7 +2183,7 @@ function createDOMPurify() {
|
|
|
2081
2183
|
*/
|
|
2082
2184
|
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
|
|
2083
2185
|
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
|
|
2084
|
-
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
2186
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && !FORBID_CONTENTS[stringToLowerCase(tagName)]) {
|
|
2085
2187
|
const parentNode = getParentNode(currentNode);
|
|
2086
2188
|
const childNodes = getChildNodes(currentNode);
|
|
2087
2189
|
if (childNodes && parentNode) {
|
|
@@ -2114,35 +2216,13 @@ function createDOMPurify() {
|
|
|
2114
2216
|
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
2115
2217
|
};
|
|
2116
2218
|
/**
|
|
2117
|
-
*
|
|
2118
|
-
*
|
|
2119
|
-
*
|
|
2120
|
-
* filtering). Per the cached, unclobberable parentNode getter the node is
|
|
2121
|
-
* genuinely out of the tree, so it can reach neither the serialized
|
|
2122
|
-
* output nor an IN_PLACE live tree; treat it as removed and stop
|
|
2123
|
-
* processing it. Without this guard, the unsafe-node / namespace checks
|
|
2124
|
-
* would call _forceRemove on a parentless node and hit the REPORT-3
|
|
2125
|
-
* fail-closed throw — which exists for nodes DOMPurify wants gone but
|
|
2126
|
-
* *cannot* detach (clobbered / parentless roots), the opposite of a node
|
|
2127
|
-
* that is already safely gone. The walk root is exempt: a detached
|
|
2128
|
-
* IN_PLACE root is legitimate input and must still be fully sanitized,
|
|
2129
|
-
* and a kill-decision on it must keep hitting the REPORT-3 throw.
|
|
2130
|
-
*
|
|
2131
|
-
* Nodes detached by hooks stay the hook's responsibility for placement:
|
|
2132
|
-
* they are not recorded in DOMPurify.removed, so the post-walk IN_PLACE
|
|
2133
|
-
* pass (which iterates DOMPurify.removed) does not reach them. But a
|
|
2134
|
-
* hook-detached subtree can still hold a queued resource-event handler -
|
|
2135
|
-
* e.g. an <img onload> that began loading when the caller built the live
|
|
2136
|
-
* tree - which fires in page scope after sanitize returns even though the
|
|
2137
|
-
* handler never reached the returned tree. That is the audit-5 F1 hazard,
|
|
2138
|
-
* and the documented node.remove() hook pattern walks straight into it.
|
|
2139
|
-
* So on the IN_PLACE path we neutralize the detached subtree inline,
|
|
2140
|
-
* stripping its non-allow-listed attributes before returning, exactly as
|
|
2141
|
-
* the post-walk pass does for _forceRemove'd subtrees.
|
|
2219
|
+
* A hook may have detached the node it was called for. If so, treat it as
|
|
2220
|
+
* removed and stop processing it; the walk root is exempt. On the IN_PLACE
|
|
2221
|
+
* path the detached subtree is neutralized right away.
|
|
2142
2222
|
*
|
|
2143
2223
|
* @param currentNode the node a hook may have detached
|
|
2144
2224
|
* @param root the current walk root
|
|
2145
|
-
* @return true if the node
|
|
2225
|
+
* @return true if the node was detached
|
|
2146
2226
|
*/
|
|
2147
2227
|
const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {
|
|
2148
2228
|
if (currentNode === root || getParentNode(currentNode) !== null) return false;
|
|
@@ -2159,6 +2239,7 @@ function createDOMPurify() {
|
|
|
2159
2239
|
* @return true if node was killed, false if left alive
|
|
2160
2240
|
*/
|
|
2161
2241
|
const _sanitizeElements = function _sanitizeElements(currentNode, root) {
|
|
2242
|
+
_markVisited(currentNode);
|
|
2162
2243
|
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
2163
2244
|
if (_handleHookDetachedNode(currentNode, root)) return true;
|
|
2164
2245
|
if (_isClobbered(currentNode)) {
|
|
@@ -2302,6 +2383,22 @@ function createDOMPurify() {
|
|
|
2302
2383
|
}
|
|
2303
2384
|
};
|
|
2304
2385
|
/**
|
|
2386
|
+
* _isUnsafeAttributeValue
|
|
2387
|
+
*
|
|
2388
|
+
* Value-based attribute checks that the attribute walk applies before any
|
|
2389
|
+
* hook can force-keep an attribute, shared with the public
|
|
2390
|
+
* isValidAttribute() so that it never approves a value sanitize() would
|
|
2391
|
+
* strip.
|
|
2392
|
+
*
|
|
2393
|
+
* @param name the attribute name as found on the node (case preserved)
|
|
2394
|
+
* @param value the attribute value
|
|
2395
|
+
* @returns true if the attribute must be removed because of its value
|
|
2396
|
+
*/
|
|
2397
|
+
const _isUnsafeAttributeValue = function _isUnsafeAttributeValue(name, value) {
|
|
2398
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) return true;
|
|
2399
|
+
return stringToLowerCase(name) === "attributename" && stringMatch(value, "href") !== null;
|
|
2400
|
+
};
|
|
2401
|
+
/**
|
|
2305
2402
|
* _sanitizeAttributes
|
|
2306
2403
|
*
|
|
2307
2404
|
* @protect attributes
|
|
@@ -2345,11 +2442,7 @@ function createDOMPurify() {
|
|
|
2345
2442
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
2346
2443
|
recreatedNamedProp = true;
|
|
2347
2444
|
}
|
|
2348
|
-
if (
|
|
2349
|
-
_removeAttribute(name, currentNode, attr);
|
|
2350
|
-
continue;
|
|
2351
|
-
}
|
|
2352
|
-
if (lcName === "attributename" && stringMatch(value, "href")) {
|
|
2445
|
+
if (_isUnsafeAttributeValue(name, value)) {
|
|
2353
2446
|
_removeAttribute(name, currentNode, attr);
|
|
2354
2447
|
continue;
|
|
2355
2448
|
}
|
|
@@ -2397,24 +2490,13 @@ function createDOMPurify() {
|
|
|
2397
2490
|
}
|
|
2398
2491
|
}
|
|
2399
2492
|
}
|
|
2493
|
+
if (SAFE_FOR_TEMPLATES) _scrubOwnCharacterData(fragment);
|
|
2400
2494
|
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
2401
2495
|
};
|
|
2402
2496
|
/**
|
|
2403
|
-
*
|
|
2404
|
-
*
|
|
2405
|
-
*
|
|
2406
|
-
* the existing _sanitizeShadowDOM pipeline. The default node iterator
|
|
2407
|
-
* does not descend into shadow trees, so nodes inside an attached
|
|
2408
|
-
* shadow root would otherwise be skipped entirely.
|
|
2409
|
-
*
|
|
2410
|
-
* Two real input paths put attached shadow roots in front of us:
|
|
2411
|
-
* 1. IN_PLACE on a DOM node that already has shadow roots attached.
|
|
2412
|
-
* 2. DOM-node input where importNode(dirty, true) deep-clones the
|
|
2413
|
-
* shadow root because it was created with `clonable: true`.
|
|
2414
|
-
*
|
|
2415
|
-
* This pass runs once, up front, so the main iteration loop (and the
|
|
2416
|
-
* existing _sanitizeShadowDOM template-content recursion) stay
|
|
2417
|
-
* untouched — string-input paths are not affected.
|
|
2497
|
+
* Sanitizes every attached shadow root under `root`, since the node
|
|
2498
|
+
* iterator does not enter shadow trees. Needed for IN_PLACE input and for
|
|
2499
|
+
* DOM input whose clonable shadow roots were copied by importNode().
|
|
2418
2500
|
*
|
|
2419
2501
|
* @param root the subtree root to walk for attached shadow roots
|
|
2420
2502
|
*/
|
|
@@ -2479,6 +2561,8 @@ function createDOMPurify() {
|
|
|
2479
2561
|
if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
2480
2562
|
DOMPurify.removed = [];
|
|
2481
2563
|
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
2564
|
+
let inPlaceNodes = [];
|
|
2565
|
+
const outerVisited = IN_PLACE_VISITED;
|
|
2482
2566
|
if (inPlace) {
|
|
2483
2567
|
_neutralizePatchLinkage(dirty);
|
|
2484
2568
|
const nn = _readNodeName(dirty);
|
|
@@ -2493,12 +2577,8 @@ function createDOMPurify() {
|
|
|
2493
2577
|
_neutralizeRoot(dirty);
|
|
2494
2578
|
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
2495
2579
|
}
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
} catch (error) {
|
|
2499
|
-
_neutralizeRoot(dirty);
|
|
2500
|
-
throw error;
|
|
2501
|
-
}
|
|
2580
|
+
inPlaceNodes = _collectLiveNodes(dirty);
|
|
2581
|
+
IN_PLACE_VISITED = setCreate();
|
|
2502
2582
|
} else if (_isNode(dirty)) {
|
|
2503
2583
|
body = _initDocument("<!---->");
|
|
2504
2584
|
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
@@ -2514,30 +2594,25 @@ function createDOMPurify() {
|
|
|
2514
2594
|
if (body && FORCE_BODY) _forceRemove(body.firstChild);
|
|
2515
2595
|
const walkRoot = inPlace ? dirty : body;
|
|
2516
2596
|
try {
|
|
2597
|
+
if (inPlace) _sanitizeAttachedShadowRoots(dirty);
|
|
2517
2598
|
const nodeIterator = _createNodeIterator(walkRoot);
|
|
2518
2599
|
while (currentNode = nodeIterator.nextNode()) {
|
|
2519
2600
|
_sanitizeElements(currentNode, walkRoot);
|
|
2520
2601
|
_sanitizeAttributes(currentNode, walkRoot);
|
|
2521
2602
|
if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
|
|
2522
2603
|
}
|
|
2604
|
+
if (inPlace) _sanitizeUnvisitedNodes(dirty, inPlaceNodes);
|
|
2523
2605
|
} catch (error) {
|
|
2524
2606
|
if (inPlace) {
|
|
2525
2607
|
_neutralizeRoot(dirty);
|
|
2526
|
-
|
|
2527
|
-
if (entry.element) _neutralizeSubtree(entry.element);
|
|
2528
|
-
});
|
|
2608
|
+
_neutralizeDiscarded(dirty, inPlaceNodes);
|
|
2529
2609
|
}
|
|
2530
2610
|
throw error;
|
|
2611
|
+
} finally {
|
|
2612
|
+
IN_PLACE_VISITED = outerVisited;
|
|
2531
2613
|
}
|
|
2532
2614
|
if (inPlace) {
|
|
2533
|
-
|
|
2534
|
-
arrayForEach(DOMPurify.removed, (entry) => {
|
|
2535
|
-
if (entry.element) {
|
|
2536
|
-
if (entry.element === dirty) rootWasRemoved = true;
|
|
2537
|
-
_neutralizeSubtree(entry.element);
|
|
2538
|
-
}
|
|
2539
|
-
});
|
|
2540
|
-
if (rootWasRemoved) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
|
|
2615
|
+
if (_neutralizeDiscarded(dirty, inPlaceNodes)) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
|
|
2541
2616
|
if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
|
|
2542
2617
|
return dirty;
|
|
2543
2618
|
}
|
|
@@ -2574,6 +2649,7 @@ function createDOMPurify() {
|
|
|
2574
2649
|
if (!CONFIG) _parseConfig({});
|
|
2575
2650
|
const lcTag = transformCaseFunc(tag);
|
|
2576
2651
|
const lcName = transformCaseFunc(attr);
|
|
2652
|
+
if (typeof value === "string" && (_isUnsafeAttributeValue(attr, value) || !ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value))) return false;
|
|
2577
2653
|
return _isValidAttribute(lcTag, lcName, value);
|
|
2578
2654
|
};
|
|
2579
2655
|
DOMPurify.addHook = function(entryPoint, hookFunction) {
|