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