@knime/product-features 6.1.0 → 6.1.2

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.
@@ -112,8 +112,8 @@ function prettyBytes(number, options) {
112
112
  return applyFixedWidth(result, options.fixedWidth);
113
113
  }
114
114
  //#endregion
115
- //#region ../../node_modules/.pnpm/dompurify@3.4.16/node_modules/dompurify/dist/purify.es.mjs
116
- /*! @license DOMPurify 3.4.16 | (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.16/LICENSE */
115
+ //#region ../../node_modules/.pnpm/dompurify@3.4.17/node_modules/dompurify/dist/purify.es.mjs
116
+ /*! @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 */
117
117
  function _OverloadYield(e, d) {
118
118
  this.v = e, this.k = d;
119
119
  }
@@ -237,9 +237,12 @@ Array.prototype.indexOf;
237
237
  var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
238
238
  var arrayPop = unapply(Array.prototype.pop);
239
239
  var arrayPush = unapply(Array.prototype.push);
240
- Array.prototype.slice;
240
+ var arraySlice = unapply(Array.prototype.slice);
241
241
  var arraySplice = unapply(Array.prototype.splice);
242
242
  var arrayIsArray = Array.isArray;
243
+ var setCreate = unconstruct(Set);
244
+ var setAdd = unapply(Set.prototype.add);
245
+ var setHas = unapply(Set.prototype.has);
243
246
  var stringToLowerCase = unapply(String.prototype.toLowerCase);
244
247
  var stringToString = unapply(String.prototype.toString);
245
248
  var stringMatch = unapply(String.prototype.match);
@@ -382,6 +385,25 @@ function lookupGetter(object, prop) {
382
385
  }
383
386
  return fallbackValue;
384
387
  }
388
+ /**
389
+ * Like lookupGetter, but for accessor properties only, and returns null
390
+ * instead of a null-returning fallback when no getter exists on the chain.
391
+ * Lets a caller fall back to a direct property read in environments that
392
+ * lack the getter, where a fallback returning null would be indistinguishable
393
+ * from a legitimate null value (e.g. namespaceURI of a no-namespace element).
394
+ *
395
+ * @param object - The object (usually a prototype) to start the lookup at.
396
+ * @param prop - The accessor property name.
397
+ * @returns The unapplied getter, or null if none was found.
398
+ */
399
+ function lookupAccessor(object, prop) {
400
+ while (object !== null) {
401
+ const desc = getOwnPropertyDescriptor(object, prop);
402
+ if (desc) return desc.get ? unapply(desc.get) : null;
403
+ object = getPrototypeOf(object);
404
+ }
405
+ return null;
406
+ }
385
407
  function isRegex(value) {
386
408
  try {
387
409
  regExpTest(value, "");
@@ -1066,7 +1088,7 @@ var NODE_TYPE = {
1066
1088
  documentFragment: 11,
1067
1089
  notation: 12
1068
1090
  };
1069
- var LITERAL_TEXT_ELEMENT_NAMES = [
1091
+ var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, [
1070
1092
  "style",
1071
1093
  "script",
1072
1094
  "xmp",
@@ -1075,15 +1097,7 @@ var LITERAL_TEXT_ELEMENT_NAMES = [
1075
1097
  "noframes",
1076
1098
  "plaintext",
1077
1099
  "noscript"
1078
- ];
1079
- var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, LITERAL_TEXT_ELEMENT_NAMES));
1080
- var LITERAL_TEXT_CLOSE = function() {
1081
- const map = {};
1082
- arrayForEach(LITERAL_TEXT_ELEMENT_NAMES, (name) => {
1083
- map[name] = seal(new RegExp("</" + name + "(?=[\\t\\n\\f\\r />])", "i"));
1084
- });
1085
- return freeze(map);
1086
- }();
1100
+ ]));
1087
1101
  var getGlobal = function getGlobal() {
1088
1102
  return typeof window === "undefined" ? null : window;
1089
1103
  };
@@ -1161,7 +1175,7 @@ var _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback)
1161
1175
  function createDOMPurify() {
1162
1176
  let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
1163
1177
  const DOMPurify = (root) => createDOMPurify(root);
1164
- DOMPurify.version = "3.4.16";
1178
+ DOMPurify.version = "3.4.17";
1165
1179
  DOMPurify.removed = [];
1166
1180
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
1167
1181
  DOMPurify.isSupported = false;
@@ -1193,6 +1207,10 @@ function createDOMPurify() {
1193
1207
  const _readNodeName = function _readNodeName(node) {
1194
1208
  return getNodeName ? getNodeName(node) : node.nodeName;
1195
1209
  };
1210
+ const getNamespaceURI = lookupAccessor(ElementPrototype, "namespaceURI");
1211
+ const _readNamespaceURI = function _readNamespaceURI(element) {
1212
+ return getNamespaceURI ? getNamespaceURI(element) : element.namespaceURI;
1213
+ };
1196
1214
  if (typeof HTMLTemplateElement === "function") {
1197
1215
  const template = document.createElement("template");
1198
1216
  if (template.content && template.content.ownerDocument) document = template.content.ownerDocument;
@@ -1313,6 +1331,7 @@ function createDOMPurify() {
1313
1331
  const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
1314
1332
  let KEEP_CONTENT = true;
1315
1333
  let IN_PLACE = false;
1334
+ let IN_PLACE_VISITED = null;
1316
1335
  let USE_PROFILES = {};
1317
1336
  let FORBID_CONTENTS = null;
1318
1337
  const DEFAULT_FORBID_CONTENTS = addToSet({}, [
@@ -1586,18 +1605,23 @@ function createDOMPurify() {
1586
1605
  * return. Return true otherwise.
1587
1606
  */
1588
1607
  const _checkValidNamespace = function _checkValidNamespace(element) {
1589
- let parent = getParentNode(element);
1590
- if (!parent || !parent.tagName) parent = {
1591
- namespaceURI: NAMESPACE,
1592
- tagName: "template"
1593
- };
1594
- const tagName = stringToLowerCase(element.tagName);
1595
- const parentTagName = stringToLowerCase(parent.tagName);
1596
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) return false;
1597
- if (element.namespaceURI === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
1598
- if (element.namespaceURI === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
1599
- if (element.namespaceURI === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
1600
- if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) return true;
1608
+ const elementNamespace = _readNamespaceURI(element);
1609
+ const tagName = stringToLowerCase(_readNodeName(element));
1610
+ const parentNode = getParentNode(element);
1611
+ let parent;
1612
+ let parentTagName;
1613
+ if (parentNode && _readNodeType(parentNode) === NODE_TYPE.element) {
1614
+ parent = { namespaceURI: _readNamespaceURI(parentNode) };
1615
+ parentTagName = stringToLowerCase(_readNodeName(parentNode));
1616
+ } else {
1617
+ parent = { namespaceURI: NAMESPACE };
1618
+ parentTagName = "template";
1619
+ }
1620
+ if (!ALLOWED_NAMESPACES[elementNamespace]) return false;
1621
+ if (elementNamespace === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
1622
+ if (elementNamespace === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
1623
+ if (elementNamespace === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
1624
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[elementNamespace]) return true;
1601
1625
  return false;
1602
1626
  };
1603
1627
  /**
@@ -1641,36 +1665,21 @@ function createDOMPurify() {
1641
1665
  }
1642
1666
  };
1643
1667
  /**
1644
- * _neutralizeRoot
1645
- *
1646
- * Fail-closed teardown of an in-place root after the sanitize walk aborts
1647
- * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
1648
- * custom element's reaction detaches a node so `_forceRemove`'s deliberate
1649
- * parentless guard throws, or any other re-entrant engine mutation — would
1650
- * otherwise leave the caller's *live* tree half-sanitized, with everything
1651
- * after the abort point still carrying its handlers. There is no safe way
1652
- * to resume the walk (the tree mutated under us), so we strip the root bare:
1653
- * remove every child and every attribute, then let the caller's catch see
1654
- * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
1655
- * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
1668
+ * Fail-closed teardown of an in-place root: strip every disallowed attribute
1669
+ * in the subtree first, so nothing armed is left behind, then remove all
1670
+ * children and the root's own attributes.
1656
1671
  *
1657
1672
  * @param root the in-place root to empty
1658
1673
  */
1659
1674
  const _neutralizeRoot = function _neutralizeRoot(root) {
1660
1675
  _neutralizeSubtree(root);
1661
1676
  const childNodes = getChildNodes(root);
1662
- if (childNodes) {
1663
- const snapshot = [];
1664
- arrayForEach(childNodes, (child) => {
1665
- arrayPush(snapshot, child);
1666
- });
1667
- arrayForEach(snapshot, (child) => {
1668
- try {
1669
- remove(child);
1670
- } catch (_) {}
1671
- });
1672
- }
1673
- const attributes = getAttributes(root);
1677
+ if (childNodes) arrayForEach(arraySlice(childNodes), (child) => {
1678
+ try {
1679
+ remove(child);
1680
+ } catch (_) {}
1681
+ });
1682
+ const attributes = _readNodeType(root) === NODE_TYPE.element ? getAttributes(root) : null;
1674
1683
  if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
1675
1684
  const attribute = attributes[i];
1676
1685
  const name = attribute && attribute.name;
@@ -1678,18 +1687,9 @@ function createDOMPurify() {
1678
1687
  }
1679
1688
  };
1680
1689
  /**
1681
- * _removeAttribute
1682
- *
1683
- * Name-based getAttributeNode()/removeAttribute() ASCII-lowercase their
1684
- * lookup key for HTML elements in an HTML document, so they silently miss an
1685
- * attribute whose stored qualified name still contains uppercase ASCII
1686
- * letters. That happens when the node came from a case-preserving source
1687
- * (an XML/XHTML document imported via importNode(), or createAttributeNS()),
1688
- * where e.g. `ONERROR` survives the walk: the policy check lowercases to
1689
- * `onerror` and rejects it, but `removeAttribute('ONERROR')` looks up
1690
- * `onerror` and finds nothing. Remove the exact Attr node instead, which is
1691
- * case- and namespace-exact, and fall back to name-based removal only when
1692
- * the caller could not supply the node.
1690
+ * Removes an attribute, preferably as its exact Attr node: name-based
1691
+ * removal lowercases the name in HTML documents and misses case-preserved
1692
+ * names, e.g. from imported XHTML.
1693
1693
  *
1694
1694
  * @param name an Attribute name
1695
1695
  * @param element a DOM node
@@ -1721,12 +1721,8 @@ function createDOMPurify() {
1721
1721
  } catch (_) {}
1722
1722
  };
1723
1723
  /**
1724
- * _stripDisallowedAttributes
1725
- *
1726
- * Removes every attribute the active configuration does not allow from a
1727
- * single element, using the same allowlist as the main attribute pass (so
1728
- * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
1729
- * neutralise nodes that are being discarded from an in-place tree.
1724
+ * Removes every attribute the configuration does not allow. Used to
1725
+ * neutralize nodes discarded from an in-place tree.
1730
1726
  *
1731
1727
  * @param element the element to strip
1732
1728
  */
@@ -1741,77 +1737,158 @@ function createDOMPurify() {
1741
1737
  }
1742
1738
  };
1743
1739
  /**
1744
- * _neutralizeSubtree
1745
- *
1746
- * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
1747
- * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
1748
- * namespace, comment, processing-instruction and KEEP_CONTENT:false removals
1749
- * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
1750
- * those dropped nodes are detached from the caller's LIVE tree but a
1751
- * handler-bearing original among them (an `<img onerror>`/`<video>` that was
1752
- * loading) keeps its queued resource event, which fires in page scope after
1753
- * sanitize returns. This walks a removed subtree and strips every attribute
1754
- * the active configuration does not allow — so `on*` handlers are cancelled
1755
- * through the SAME allowlist that governs kept nodes, not a separate `/^on/`
1756
- * blocklist. Run synchronously before sanitize returns, i.e. before any
1757
- * queued event can fire. Hook-free by design: these nodes leave the output,
1758
- * so firing attribute hooks for them would be surprising. Clobber-safe reads;
1759
- * a doomed clobbered node may shadow `removeAttribute` (its own attributes are
1760
- * irrelevant — it is discarded — while its non-clobbered descendants, e.g.
1761
- * the `<img>`, are reached and scrubbed).
1740
+ * Iterative depth-first walk, so deep trees cannot overflow the call stack,
1741
+ * reading through the cached getters, so clobbering cannot hide children.
1742
+ * When `visit` returns false, the node's children are skipped. With
1743
+ * `intoShadow`, open shadow roots are walked after their host's children.
1762
1744
  *
1763
- * @param root the root of a removed subtree to neutralise
1745
+ * @param root where to start
1746
+ * @param visit called for every node
1747
+ * @param intoShadow whether to enter open shadow roots
1764
1748
  */
1765
- const _neutralizeSubtree = function _neutralizeSubtree(root) {
1749
+ const _walkTree = function _walkTree(root, visit) {
1750
+ let intoShadow = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
1766
1751
  const stack = [root];
1767
1752
  while (stack.length > 0) {
1768
1753
  const node = stack.pop();
1769
- if (_readNodeType(node) === NODE_TYPE.element) _stripDisallowedAttributes(node);
1754
+ if (visit(node) === false) continue;
1755
+ if (intoShadow && _readNodeType(node) === NODE_TYPE.element) {
1756
+ const shadowRoot = getShadowRoot(node);
1757
+ if (_isDocumentFragment(shadowRoot)) stack.push(shadowRoot);
1758
+ }
1770
1759
  const childNodes = getChildNodes(node);
1771
1760
  if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
1772
1761
  }
1773
1762
  };
1774
1763
  /**
1775
- * _neutralizePatchLinkage
1764
+ * Strips disallowed attributes from every element of a discarded subtree,
1765
+ * so a handler that is already queued (a loading image) cannot fire.
1776
1766
  *
1777
- * IN_PLACE entry pre-pass (declarative-partial-updates / streaming
1778
- * hardening, https://github.com/WICG/declarative-partial-updates).
1767
+ * @param root the root of a removed subtree
1768
+ */
1769
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
1770
+ _walkTree(root, (node) => {
1771
+ if (_readNodeType(node) === NODE_TYPE.element) _stripDisallowedAttributes(node);
1772
+ });
1773
+ };
1774
+ /**
1775
+ * All nodes under `root`, root first, including open shadow roots. Template
1776
+ * content is not entered, it is inert.
1779
1777
  *
1780
- * The main walk strips patch linkage (`for`/`patchsrc`) and removes range
1781
- * markers (PIs / markup comments) node-by-node, in document order, AS it
1782
- * reaches each node. On a live in-place root that leaves a window: from the
1783
- * moment the root is connected until the walk arrives at a given node, that
1784
- * node's linkage is live. A patch applied on connection/stream can fire as
1785
- * a microtask during the walk and inject or teleport an unsanitized DOM
1786
- * range into a region the iterator has already passed and will not revisit,
1787
- * so the post-return "tree is sanitized" contract is violated. Sweep the
1788
- * whole tree once up front and sever every linkage before the walk begins,
1789
- * closing that window.
1778
+ * @param root the in-place root
1779
+ * @return the nodes
1780
+ */
1781
+ const _collectLiveNodes = function _collectLiveNodes(root) {
1782
+ const nodes = [];
1783
+ _walkTree(root, (node) => {
1784
+ nodes.push(node);
1785
+ }, true);
1786
+ return nodes;
1787
+ };
1788
+ /**
1789
+ * Strips disallowed attributes from every element that was under the
1790
+ * in-place root when the call started and no longer is, whatever removed
1791
+ * or moved it.
1790
1792
  *
1791
- * This CANNOT undo a patch that already fired before sanitize ran — that is
1792
- * the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
1793
- * but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
1794
- * to group with the rest of the declarative-partial-updates handling and
1795
- * stay overridable, consistent with the codebase.
1793
+ * @param root the in-place root
1794
+ * @param before the root's nodes, collected before the walk
1795
+ */
1796
+ const _neutralizeEscapedElements = function _neutralizeEscapedElements(root, before) {
1797
+ const reachable = setCreate();
1798
+ arrayForEach(_collectLiveNodes(root), (node) => {
1799
+ if (_readNodeType(node) === NODE_TYPE.element) setAdd(reachable, node);
1800
+ });
1801
+ arrayForEach(before, (node) => {
1802
+ if (_readNodeType(node) === NODE_TYPE.element && !setHas(reachable, node)) _stripDisallowedAttributes(node);
1803
+ });
1804
+ };
1805
+ /**
1806
+ * Neutralizes everything that left the in-place tree during the call: what
1807
+ * DOMPurify removed, and what hooks or custom elements removed or moved out.
1796
1808
  *
1797
- * Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
1798
- * clobbered root cannot defeat the sweep of its non-clobbered descendants.
1809
+ * @param root the in-place root
1810
+ * @param before the root's nodes, collected before the walk
1811
+ * @return true if the root itself was removed
1812
+ */
1813
+ const _neutralizeDiscarded = function _neutralizeDiscarded(root, before) {
1814
+ let rootRemoved = false;
1815
+ arrayForEach(DOMPurify.removed, (entry) => {
1816
+ if (entry.element) {
1817
+ rootRemoved = rootRemoved || entry.element === root;
1818
+ _neutralizeSubtree(entry.element);
1819
+ }
1820
+ });
1821
+ _neutralizeEscapedElements(root, before);
1822
+ return rootRemoved;
1823
+ };
1824
+ const MAX_UNVISITED_ROUNDS = 8;
1825
+ /**
1826
+ * The walk only moves forward, so a node moved to a position it already
1827
+ * passed is never visited. Give every original node that is still in the
1828
+ * tree but unvisited the normal treatment, hooks included. Nodes created
1829
+ * during the call are left alone. Fails closed if the tree keeps changing.
1799
1830
  *
1800
- * NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
1801
- * .html Q1): this mirrors the existing policy of keeping `for` on
1802
- * <label>/<output>. If the shipping feature can drive a patch through a
1803
- * surviving `for`-on-label/output + `id` pair, this pre-pass and the
1804
- * attribute check at _isBasicCustomElement's caller must additionally drop
1805
- * that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
1831
+ * @param root the in-place root
1832
+ * @param before the root's nodes, collected before the walk
1833
+ */
1834
+ const _sanitizeUnvisitedNodes = function _sanitizeUnvisitedNodes(root, before) {
1835
+ const visited = IN_PLACE_VISITED;
1836
+ let original = null;
1837
+ const getOriginal = () => {
1838
+ if (!original) {
1839
+ original = setCreate();
1840
+ arrayForEach(before, (beforeNode) => {
1841
+ setAdd(original, beforeNode);
1842
+ });
1843
+ }
1844
+ return original;
1845
+ };
1846
+ for (let round = 0;; round++) {
1847
+ const live = _collectLiveNodes(root);
1848
+ const containers = [root];
1849
+ let pending = false;
1850
+ arrayForEach(live, (node) => {
1851
+ if (_readNodeType(node) === NODE_TYPE.documentFragment) arrayPush(containers, node);
1852
+ else if (!pending && !setHas(visited, node)) pending = setHas(getOriginal(), node);
1853
+ });
1854
+ if (!pending) return;
1855
+ if (round >= MAX_UNVISITED_ROUNDS) throw typeErrorCreate("the tree kept changing during in-place sanitization; refusing to return it");
1856
+ arrayForEach(containers, (container, index) => {
1857
+ _sanitizeUnvisitedIn(container, index > 0, root, getOriginal());
1858
+ });
1859
+ }
1860
+ };
1861
+ /**
1862
+ * One _sanitizeUnvisitedNodes pass over the root or an open shadow root.
1806
1863
  *
1807
- * @param root the in-place root to sweep
1864
+ * @param container the root or an open shadow root
1865
+ * @param inShadow whether container is a shadow root
1866
+ * @param root the in-place root
1867
+ * @param original the root's nodes collected before the walk, as a set
1808
1868
  */
1869
+ const _sanitizeUnvisitedIn = function _sanitizeUnvisitedIn(container, inShadow, root, original) {
1870
+ const iterator = _createNodeIterator(container);
1871
+ let node;
1872
+ while (node = iterator.nextNode()) {
1873
+ if (!setHas(original, node) || setHas(IN_PLACE_VISITED, node)) continue;
1874
+ if (inShadow) _executeHooks(hooks.uponSanitizeShadowNode, node, null);
1875
+ _sanitizeElements(node, root);
1876
+ _sanitizeAttributes(node, root);
1877
+ if (_isDocumentFragment(node.content)) _sanitizeShadowDOM2(node.content);
1878
+ }
1879
+ };
1880
+ /**
1881
+ * Records that _sanitizeElements processed `node`. No-op outside IN_PLACE.
1882
+ *
1883
+ * @param node the node being processed
1884
+ */
1885
+ const _markVisited = function _markVisited(node) {
1886
+ if (IN_PLACE_VISITED) setAdd(IN_PLACE_VISITED, node);
1887
+ };
1809
1888
  /**
1810
- * Central policy for declarative-partial-updates patch-linkage attributes,
1811
- * shared by the _neutralizePatchLinkage pre-pass and _isValidAttribute so
1812
- * the two sites cannot drift: `patchsrc` always links, `for` links
1813
- * everywhere except on <label>/<output>, and the whole policy is gated on
1814
- * SAFE_FOR_XML (see the rationale block in _isValidAttribute).
1889
+ * Patch-linkage attributes (declarative partial updates): `patchsrc`
1890
+ * always, `for` everywhere except on <label> and <output>. Gated on
1891
+ * SAFE_FOR_XML. Shared by the IN_PLACE pre-pass and _isValidAttribute.
1815
1892
  *
1816
1893
  * @param lcName the transformCaseFunc'd attribute name
1817
1894
  * @param lcTag the transformCaseFunc'd tag name of the carrying element
@@ -1822,17 +1899,26 @@ function createDOMPurify() {
1822
1899
  if (lcName === "patchsrc") return true;
1823
1900
  return lcName === "for" && lcTag !== "label" && lcTag !== "output";
1824
1901
  };
1902
+ /**
1903
+ * IN_PLACE pre-pass: sever all patch linkage before the walk, so no patch
1904
+ * can fire mid-walk into a part of the tree the walker already passed.
1905
+ * Removes range markers (processing instructions, comments with markup)
1906
+ * and strips linkage attributes. It cannot undo a patch that already fired.
1907
+ *
1908
+ * TODO: if the shipped feature can patch through `for` on <label>/<output>,
1909
+ * drop that pair here too (see test/declarative-patch-probe.html).
1910
+ *
1911
+ * @param root the in-place root to sweep
1912
+ */
1825
1913
  const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
1826
1914
  if (!SAFE_FOR_XML) return;
1827
- const stack = [root];
1828
- while (stack.length > 0) {
1829
- const node = stack.pop();
1915
+ _walkTree(root, (node) => {
1830
1916
  const nodeType = _readNodeType(node);
1831
1917
  if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
1832
1918
  try {
1833
1919
  remove(node);
1834
1920
  } catch (_) {}
1835
- continue;
1921
+ return false;
1836
1922
  }
1837
1923
  if (nodeType === NODE_TYPE.element) {
1838
1924
  const element = node;
@@ -1842,9 +1928,8 @@ function createDOMPurify() {
1842
1928
  if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) element.removeAttribute("for");
1843
1929
  } catch (_) {}
1844
1930
  }
1845
- const childNodes = getChildNodes(node);
1846
- if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
1847
- }
1931
+ return true;
1932
+ });
1848
1933
  };
1849
1934
  /**
1850
1935
  * _initDocument
@@ -1921,6 +2006,27 @@ function createDOMPurify() {
1921
2006
  */
1922
2007
  const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
1923
2008
  var _node$querySelectorAl;
2009
+ _scrubOwnCharacterData(node);
2010
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
2011
+ if (templates) arrayForEach(templates, (tmpl) => {
2012
+ if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
2013
+ });
2014
+ };
2015
+ /**
2016
+ * _scrubOwnCharacterData
2017
+ *
2018
+ * Non-recursive core of _scrubTemplateExpressions: normalize `node` and
2019
+ * strip template expressions from its own character data only. Does not
2020
+ * enter <template>.content or attached shadow roots (NodeIterator never
2021
+ * does). Used by _sanitizeShadowDOM, where every nested template content
2022
+ * and shadow root is already walked - and therefore scrubbed - by its own
2023
+ * recursive _sanitizeShadowDOM call; recursing here as well would rescrub
2024
+ * each nested fragment once per ancestor, which is quadratic in nesting
2025
+ * depth.
2026
+ *
2027
+ * @param node The root whose own character data should be scrubbed.
2028
+ */
2029
+ const _scrubOwnCharacterData = function _scrubOwnCharacterData(node) {
1924
2030
  node.normalize();
1925
2031
  const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
1926
2032
  const walker = createNodeIterator.call(doc || node, node, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
@@ -1929,10 +2035,6 @@ function createDOMPurify() {
1929
2035
  currentNode.data = _stripTemplateExpressions(currentNode.data);
1930
2036
  currentNode = walker.nextNode();
1931
2037
  }
1932
- const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
1933
- if (templates) arrayForEach(templates, (tmpl) => {
1934
- if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
1935
- });
1936
2038
  };
1937
2039
  /**
1938
2040
  * _isClobbered
@@ -2008,7 +2110,7 @@ function createDOMPurify() {
2008
2110
  */
2009
2111
  const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
2010
2112
  if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
2011
- if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && LITERAL_TEXT_ELEMENTS[tagName] && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(LITERAL_TEXT_CLOSE[tagName], currentNode.textContent))) return true;
2113
+ 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;
2012
2114
  if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
2013
2115
  if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
2014
2116
  return false;
@@ -2052,7 +2154,7 @@ function createDOMPurify() {
2052
2154
  */
2053
2155
  const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
2054
2156
  if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
2055
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
2157
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && !FORBID_CONTENTS[stringToLowerCase(tagName)]) {
2056
2158
  const parentNode = getParentNode(currentNode);
2057
2159
  const childNodes = getChildNodes(currentNode);
2058
2160
  if (childNodes && parentNode) {
@@ -2085,35 +2187,13 @@ function createDOMPurify() {
2085
2187
  return set === defaultSet || set === setConfigSet ? clone(set) : set;
2086
2188
  };
2087
2189
  /**
2088
- * Shared guard for a node that a hook has detached from the walk tree,
2089
- * used after each element-hook site in _sanitizeElements. Detaching is a
2090
- * long-standing user pattern (issue #469; draw.io-style foreignObject
2091
- * filtering). Per the cached, unclobberable parentNode getter the node is
2092
- * genuinely out of the tree, so it can reach neither the serialized
2093
- * output nor an IN_PLACE live tree; treat it as removed and stop
2094
- * processing it. Without this guard, the unsafe-node / namespace checks
2095
- * would call _forceRemove on a parentless node and hit the REPORT-3
2096
- * fail-closed throw — which exists for nodes DOMPurify wants gone but
2097
- * *cannot* detach (clobbered / parentless roots), the opposite of a node
2098
- * that is already safely gone. The walk root is exempt: a detached
2099
- * IN_PLACE root is legitimate input and must still be fully sanitized,
2100
- * and a kill-decision on it must keep hitting the REPORT-3 throw.
2101
- *
2102
- * Nodes detached by hooks stay the hook's responsibility for placement:
2103
- * they are not recorded in DOMPurify.removed, so the post-walk IN_PLACE
2104
- * pass (which iterates DOMPurify.removed) does not reach them. But a
2105
- * hook-detached subtree can still hold a queued resource-event handler -
2106
- * e.g. an <img onload> that began loading when the caller built the live
2107
- * tree - which fires in page scope after sanitize returns even though the
2108
- * handler never reached the returned tree. That is the audit-5 F1 hazard,
2109
- * and the documented node.remove() hook pattern walks straight into it.
2110
- * So on the IN_PLACE path we neutralize the detached subtree inline,
2111
- * stripping its non-allow-listed attributes before returning, exactly as
2112
- * the post-walk pass does for _forceRemove'd subtrees.
2190
+ * A hook may have detached the node it was called for. If so, treat it as
2191
+ * removed and stop processing it; the walk root is exempt. On the IN_PLACE
2192
+ * path the detached subtree is neutralized right away.
2113
2193
  *
2114
2194
  * @param currentNode the node a hook may have detached
2115
2195
  * @param root the current walk root
2116
- * @return true if the node is detached and now handled, false otherwise
2196
+ * @return true if the node was detached
2117
2197
  */
2118
2198
  const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {
2119
2199
  if (currentNode === root || getParentNode(currentNode) !== null) return false;
@@ -2130,6 +2210,7 @@ function createDOMPurify() {
2130
2210
  * @return true if node was killed, false if left alive
2131
2211
  */
2132
2212
  const _sanitizeElements = function _sanitizeElements(currentNode, root) {
2213
+ _markVisited(currentNode);
2133
2214
  _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
2134
2215
  if (_handleHookDetachedNode(currentNode, root)) return true;
2135
2216
  if (_isClobbered(currentNode)) {
@@ -2273,6 +2354,22 @@ function createDOMPurify() {
2273
2354
  }
2274
2355
  };
2275
2356
  /**
2357
+ * _isUnsafeAttributeValue
2358
+ *
2359
+ * Value-based attribute checks that the attribute walk applies before any
2360
+ * hook can force-keep an attribute, shared with the public
2361
+ * isValidAttribute() so that it never approves a value sanitize() would
2362
+ * strip.
2363
+ *
2364
+ * @param name the attribute name as found on the node (case preserved)
2365
+ * @param value the attribute value
2366
+ * @returns true if the attribute must be removed because of its value
2367
+ */
2368
+ const _isUnsafeAttributeValue = function _isUnsafeAttributeValue(name, value) {
2369
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) return true;
2370
+ return stringToLowerCase(name) === "attributename" && stringMatch(value, "href") !== null;
2371
+ };
2372
+ /**
2276
2373
  * _sanitizeAttributes
2277
2374
  *
2278
2375
  * @protect attributes
@@ -2316,11 +2413,7 @@ function createDOMPurify() {
2316
2413
  value = SANITIZE_NAMED_PROPS_PREFIX + value;
2317
2414
  recreatedNamedProp = true;
2318
2415
  }
2319
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
2320
- _removeAttribute(name, currentNode, attr);
2321
- continue;
2322
- }
2323
- if (lcName === "attributename" && stringMatch(value, "href")) {
2416
+ if (_isUnsafeAttributeValue(name, value)) {
2324
2417
  _removeAttribute(name, currentNode, attr);
2325
2418
  continue;
2326
2419
  }
@@ -2368,24 +2461,13 @@ function createDOMPurify() {
2368
2461
  }
2369
2462
  }
2370
2463
  }
2464
+ if (SAFE_FOR_TEMPLATES) _scrubOwnCharacterData(fragment);
2371
2465
  _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
2372
2466
  };
2373
2467
  /**
2374
- * _sanitizeAttachedShadowRoots
2375
- *
2376
- * Walks `root` and feeds every attached shadow root we encounter into
2377
- * the existing _sanitizeShadowDOM pipeline. The default node iterator
2378
- * does not descend into shadow trees, so nodes inside an attached
2379
- * shadow root would otherwise be skipped entirely.
2380
- *
2381
- * Two real input paths put attached shadow roots in front of us:
2382
- * 1. IN_PLACE on a DOM node that already has shadow roots attached.
2383
- * 2. DOM-node input where importNode(dirty, true) deep-clones the
2384
- * shadow root because it was created with `clonable: true`.
2385
- *
2386
- * This pass runs once, up front, so the main iteration loop (and the
2387
- * existing _sanitizeShadowDOM template-content recursion) stay
2388
- * untouched — string-input paths are not affected.
2468
+ * Sanitizes every attached shadow root under `root`, since the node
2469
+ * iterator does not enter shadow trees. Needed for IN_PLACE input and for
2470
+ * DOM input whose clonable shadow roots were copied by importNode().
2389
2471
  *
2390
2472
  * @param root the subtree root to walk for attached shadow roots
2391
2473
  */
@@ -2450,6 +2532,8 @@ function createDOMPurify() {
2450
2532
  if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
2451
2533
  DOMPurify.removed = [];
2452
2534
  const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
2535
+ let inPlaceNodes = [];
2536
+ const outerVisited = IN_PLACE_VISITED;
2453
2537
  if (inPlace) {
2454
2538
  _neutralizePatchLinkage(dirty);
2455
2539
  const nn = _readNodeName(dirty);
@@ -2464,12 +2548,8 @@ function createDOMPurify() {
2464
2548
  _neutralizeRoot(dirty);
2465
2549
  throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
2466
2550
  }
2467
- try {
2468
- _sanitizeAttachedShadowRoots(dirty);
2469
- } catch (error) {
2470
- _neutralizeRoot(dirty);
2471
- throw error;
2472
- }
2551
+ inPlaceNodes = _collectLiveNodes(dirty);
2552
+ IN_PLACE_VISITED = setCreate();
2473
2553
  } else if (_isNode(dirty)) {
2474
2554
  body = _initDocument("<!---->");
2475
2555
  importedNode = body.ownerDocument.importNode(dirty, true);
@@ -2485,30 +2565,25 @@ function createDOMPurify() {
2485
2565
  if (body && FORCE_BODY) _forceRemove(body.firstChild);
2486
2566
  const walkRoot = inPlace ? dirty : body;
2487
2567
  try {
2568
+ if (inPlace) _sanitizeAttachedShadowRoots(dirty);
2488
2569
  const nodeIterator = _createNodeIterator(walkRoot);
2489
2570
  while (currentNode = nodeIterator.nextNode()) {
2490
2571
  _sanitizeElements(currentNode, walkRoot);
2491
2572
  _sanitizeAttributes(currentNode, walkRoot);
2492
2573
  if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
2493
2574
  }
2575
+ if (inPlace) _sanitizeUnvisitedNodes(dirty, inPlaceNodes);
2494
2576
  } catch (error) {
2495
2577
  if (inPlace) {
2496
2578
  _neutralizeRoot(dirty);
2497
- arrayForEach(DOMPurify.removed, (entry) => {
2498
- if (entry.element) _neutralizeSubtree(entry.element);
2499
- });
2579
+ _neutralizeDiscarded(dirty, inPlaceNodes);
2500
2580
  }
2501
2581
  throw error;
2582
+ } finally {
2583
+ IN_PLACE_VISITED = outerVisited;
2502
2584
  }
2503
2585
  if (inPlace) {
2504
- let rootWasRemoved = false;
2505
- arrayForEach(DOMPurify.removed, (entry) => {
2506
- if (entry.element) {
2507
- if (entry.element === dirty) rootWasRemoved = true;
2508
- _neutralizeSubtree(entry.element);
2509
- }
2510
- });
2511
- if (rootWasRemoved) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
2586
+ if (_neutralizeDiscarded(dirty, inPlaceNodes)) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
2512
2587
  if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
2513
2588
  return dirty;
2514
2589
  }
@@ -2545,6 +2620,7 @@ function createDOMPurify() {
2545
2620
  if (!CONFIG) _parseConfig({});
2546
2621
  const lcTag = transformCaseFunc(tag);
2547
2622
  const lcName = transformCaseFunc(attr);
2623
+ if (typeof value === "string" && (_isUnsafeAttributeValue(attr, value) || !ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value))) return false;
2548
2624
  return _isValidAttribute(lcTag, lcName, value);
2549
2625
  };
2550
2626
  DOMPurify.addHook = function(entryPoint, hookFunction) {
@@ -2903,4 +2979,4 @@ Object.values({
2903
2979
  //#endregion
2904
2980
  export { getFileExtension as a, promise_exports as c, formatLocalDateTimeString as i, sleep as l, formatDateTimeString as n, getFileMimeType as o, formatFileSize as r, knimeFileFormats as s, capitalize as t, truncateString_default as u };
2905
2981
 
2906
- //# sourceMappingURL=dist-DtdyvuFe.js.map
2982
+ //# sourceMappingURL=dist-htLRPkoq.js.map