@nsshunt/stsuxvue 1.0.125 → 1.0.126

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/dist/stsuxvue.cjs CHANGED
@@ -6036,7 +6036,7 @@ var import_ansi_to_html = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin
6036
6036
  return Filter;
6037
6037
  }();
6038
6038
  })))(), 1);
6039
- /*! @license DOMPurify 3.4.8 | (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.8/LICENSE */
6039
+ /*! @license DOMPurify 3.4.9 | (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.9/LICENSE */
6040
6040
  function _arrayLikeToArray(r, a) {
6041
6041
  (null == a || a > r.length) && (a = r.length);
6042
6042
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -6965,7 +6965,7 @@ var _createHooksMap = function _createHooksMap() {
6965
6965
  function createDOMPurify() {
6966
6966
  let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal$1();
6967
6967
  const DOMPurify = (root) => createDOMPurify(root);
6968
- DOMPurify.version = "3.4.8";
6968
+ DOMPurify.version = "3.4.9";
6969
6969
  DOMPurify.removed = [];
6970
6970
  if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
6971
6971
  DOMPurify.isSupported = false;
@@ -6995,15 +6995,36 @@ function createDOMPurify() {
6995
6995
  }
6996
6996
  let trustedTypesPolicy;
6997
6997
  let emptyHTML = "";
6998
- let IN_POLICY_CREATE_HTML = 0;
6998
+ let defaultTrustedTypesPolicy;
6999
+ let defaultTrustedTypesPolicyResolved = false;
7000
+ let IN_TRUSTED_TYPES_POLICY = 0;
7001
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
7002
+ if (IN_TRUSTED_TYPES_POLICY > 0) throw typeErrorCreate("A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the \"DOMPurify and Trusted Types\" section of the README.");
7003
+ };
6999
7004
  const _createTrustedHTML = function _createTrustedHTML(html) {
7000
- if (IN_POLICY_CREATE_HTML > 0) throw typeErrorCreate("The configured TRUSTED_TYPES_POLICY.createHTML must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose createHTML wraps DOMPurify as TRUSTED_TYPES_POLICY; see the \"DOMPurify and Trusted Types\" section of the README.");
7001
- IN_POLICY_CREATE_HTML++;
7005
+ _assertNotInTrustedTypesPolicy();
7006
+ IN_TRUSTED_TYPES_POLICY++;
7002
7007
  try {
7003
7008
  return trustedTypesPolicy.createHTML(html);
7004
7009
  } finally {
7005
- IN_POLICY_CREATE_HTML--;
7010
+ IN_TRUSTED_TYPES_POLICY--;
7011
+ }
7012
+ };
7013
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
7014
+ _assertNotInTrustedTypesPolicy();
7015
+ IN_TRUSTED_TYPES_POLICY++;
7016
+ try {
7017
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
7018
+ } finally {
7019
+ IN_TRUSTED_TYPES_POLICY--;
7020
+ }
7021
+ };
7022
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
7023
+ if (!defaultTrustedTypesPolicyResolved) {
7024
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
7025
+ defaultTrustedTypesPolicyResolved = true;
7006
7026
  }
7027
+ return defaultTrustedTypesPolicy;
7007
7028
  };
7008
7029
  const _document = document, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
7009
7030
  const importNode = originalDocument.importNode;
@@ -7107,6 +7128,7 @@ function createDOMPurify() {
7107
7128
  "noscript",
7108
7129
  "plaintext",
7109
7130
  "script",
7131
+ "selectedcontent",
7110
7132
  "style",
7111
7133
  "svg",
7112
7134
  "template",
@@ -7298,8 +7320,11 @@ function createDOMPurify() {
7298
7320
  trustedTypesPolicy = previousTrustedTypesPolicy;
7299
7321
  throw error;
7300
7322
  }
7323
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
7324
+ trustedTypesPolicy = void 0;
7325
+ emptyHTML = "";
7301
7326
  } else {
7302
- if (trustedTypesPolicy === void 0 && cfg.TRUSTED_TYPES_POLICY !== null) trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
7327
+ if (trustedTypesPolicy === void 0) trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
7303
7328
  if (trustedTypesPolicy && typeof emptyHTML === "string") emptyHTML = _createTrustedHTML("");
7304
7329
  }
7305
7330
  if ((hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) && ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) ALLOWED_TAGS = clone(ALLOWED_TAGS);
@@ -7357,6 +7382,45 @@ function createDOMPurify() {
7357
7382
  getParentNode(node).removeChild(node);
7358
7383
  } catch (_) {
7359
7384
  remove(node);
7385
+ if (!getParentNode(node)) throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
7386
+ }
7387
+ };
7388
+ /**
7389
+ * _neutralizeRoot
7390
+ *
7391
+ * Fail-closed teardown of an in-place root after the sanitize walk aborts
7392
+ * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
7393
+ * custom element's reaction detaches a node so `_forceRemove`'s deliberate
7394
+ * parentless guard throws, or any other re-entrant engine mutation — would
7395
+ * otherwise leave the caller's *live* tree half-sanitized, with everything
7396
+ * after the abort point still carrying its handlers. There is no safe way
7397
+ * to resume the walk (the tree mutated under us), so we strip the root bare:
7398
+ * remove every child and every attribute, then let the caller's catch see
7399
+ * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
7400
+ * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
7401
+ *
7402
+ * @param root the in-place root to empty
7403
+ */
7404
+ const _neutralizeRoot = function _neutralizeRoot(root) {
7405
+ const childNodes = getChildNodes ? getChildNodes(root) : root.childNodes;
7406
+ if (childNodes) {
7407
+ const snapshot = [];
7408
+ arrayForEach(childNodes, (child) => {
7409
+ arrayPush(snapshot, child);
7410
+ });
7411
+ arrayForEach(snapshot, (child) => {
7412
+ try {
7413
+ remove(child);
7414
+ } catch (_) {}
7415
+ });
7416
+ }
7417
+ const attributes = getAttributes ? getAttributes(root) : null;
7418
+ if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
7419
+ const attribute = attributes[i];
7420
+ const name = attribute && attribute.name;
7421
+ if (typeof name === "string") try {
7422
+ root.removeAttribute(name);
7423
+ } catch (_) {}
7360
7424
  }
7361
7425
  };
7362
7426
  /**
@@ -7386,6 +7450,59 @@ function createDOMPurify() {
7386
7450
  } catch (_) {}
7387
7451
  };
7388
7452
  /**
7453
+ * _stripDisallowedAttributes
7454
+ *
7455
+ * Removes every attribute the active configuration does not allow from a
7456
+ * single element, using the same allowlist as the main attribute pass (so
7457
+ * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
7458
+ * neutralise nodes that are being discarded from an in-place tree.
7459
+ *
7460
+ * @param element the element to strip
7461
+ */
7462
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
7463
+ const attributes = getAttributes ? getAttributes(element) : element.attributes;
7464
+ if (!attributes) return;
7465
+ for (let i = attributes.length - 1; i >= 0; --i) {
7466
+ const attribute = attributes[i];
7467
+ const name = attribute && attribute.name;
7468
+ if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) continue;
7469
+ try {
7470
+ element.removeAttribute(name);
7471
+ } catch (_) {}
7472
+ }
7473
+ };
7474
+ /**
7475
+ * _neutralizeSubtree
7476
+ *
7477
+ * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
7478
+ * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
7479
+ * namespace, comment, processing-instruction and KEEP_CONTENT:false removals
7480
+ * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
7481
+ * those dropped nodes are detached from the caller's LIVE tree but a
7482
+ * handler-bearing original among them (an `<img onerror>`/`<video>` that was
7483
+ * loading) keeps its queued resource event, which fires in page scope after
7484
+ * sanitize returns. This walks a removed subtree and strips every attribute
7485
+ * the active configuration does not allow — so `on*` handlers are cancelled
7486
+ * through the SAME allowlist that governs kept nodes, not a separate `/^on/`
7487
+ * blocklist. Run synchronously before sanitize returns, i.e. before any
7488
+ * queued event can fire. Hook-free by design: these nodes leave the output,
7489
+ * so firing attribute hooks for them would be surprising. Clobber-safe reads;
7490
+ * a doomed clobbered node may shadow `removeAttribute` (its own attributes are
7491
+ * irrelevant — it is discarded — while its non-clobbered descendants, e.g.
7492
+ * the `<img>`, are reached and scrubbed).
7493
+ *
7494
+ * @param root the root of a removed subtree to neutralise
7495
+ */
7496
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
7497
+ const stack = [root];
7498
+ while (stack.length > 0) {
7499
+ const node = stack.pop();
7500
+ if ((getNodeType ? getNodeType(node) : node.nodeType) === NODE_TYPE.element) _stripDisallowedAttributes(node);
7501
+ const childNodes = getChildNodes ? getChildNodes(node) : node.childNodes;
7502
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
7503
+ }
7504
+ };
7505
+ /**
7389
7506
  * _initDocument
7390
7507
  *
7391
7508
  * @param dirty - a string of dirty markup
@@ -7574,8 +7691,8 @@ function createDOMPurify() {
7574
7691
  if (childNodes && parentNode) {
7575
7692
  const childCount = childNodes.length;
7576
7693
  for (let i = childCount - 1; i >= 0; --i) {
7577
- const childClone = cloneNode(childNodes[i], true);
7578
- parentNode.insertBefore(childClone, getNextSibling(currentNode));
7694
+ const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
7695
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
7579
7696
  }
7580
7697
  }
7581
7698
  }
@@ -7724,7 +7841,7 @@ function createDOMPurify() {
7724
7841
  value = _createTrustedHTML(value);
7725
7842
  break;
7726
7843
  case "TrustedScriptURL":
7727
- value = trustedTypesPolicy.createScriptURL(value);
7844
+ value = _createTrustedScriptURL(value);
7728
7845
  break;
7729
7846
  }
7730
7847
  if (value !== initValue) try {
@@ -7755,7 +7872,7 @@ function createDOMPurify() {
7755
7872
  if ((getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType) === NODE_TYPE.element) {
7756
7873
  const innerSr = getShadowRoot ? getShadowRoot(shadowNode) : shadowNode.shadowRoot;
7757
7874
  if (_isDocumentFragment(innerSr)) {
7758
- _sanitizeAttachedShadowRoots2(innerSr);
7875
+ _sanitizeAttachedShadowRoots(innerSr);
7759
7876
  _sanitizeShadowDOM2(innerSr);
7760
7877
  }
7761
7878
  }
@@ -7781,27 +7898,43 @@ function createDOMPurify() {
7781
7898
  *
7782
7899
  * @param root the subtree root to walk for attached shadow roots
7783
7900
  */
7784
- const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root) {
7785
- const nodeType = getNodeType ? getNodeType(root) : root.nodeType;
7786
- if (nodeType === NODE_TYPE.element) {
7787
- const sr = getShadowRoot ? getShadowRoot(root) : root.shadowRoot;
7788
- if (_isDocumentFragment(sr)) {
7789
- _sanitizeAttachedShadowRoots2(sr);
7790
- _sanitizeShadowDOM2(sr);
7901
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
7902
+ const stack = [{
7903
+ node: root,
7904
+ shadow: null
7905
+ }];
7906
+ while (stack.length > 0) {
7907
+ const item = stack.pop();
7908
+ if (item.shadow) {
7909
+ _sanitizeShadowDOM2(item.shadow);
7910
+ continue;
7791
7911
  }
7792
- }
7793
- const childNodes = getChildNodes ? getChildNodes(root) : root.childNodes;
7794
- if (!childNodes) return;
7795
- const snapshot = [];
7796
- arrayForEach(childNodes, (child) => {
7797
- arrayPush(snapshot, child);
7798
- });
7799
- for (const child of snapshot) _sanitizeAttachedShadowRoots2(child);
7800
- if (nodeType === NODE_TYPE.element) {
7801
- const rootName = getNodeName ? getNodeName(root) : null;
7802
- if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
7803
- const content = root.content;
7804
- if (_isDocumentFragment(content)) _sanitizeAttachedShadowRoots2(content);
7912
+ const node = item.node;
7913
+ const isElement = (getNodeType ? getNodeType(node) : node.nodeType) === NODE_TYPE.element;
7914
+ const childNodes = getChildNodes ? getChildNodes(node) : node.childNodes;
7915
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
7916
+ node: childNodes[i],
7917
+ shadow: null
7918
+ });
7919
+ if (isElement) {
7920
+ const rootName = getNodeName ? getNodeName(node) : null;
7921
+ if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
7922
+ const content = node.content;
7923
+ if (_isDocumentFragment(content)) stack.push({
7924
+ node: content,
7925
+ shadow: null
7926
+ });
7927
+ }
7928
+ }
7929
+ if (isElement) {
7930
+ const sr = getShadowRoot ? getShadowRoot(node) : node.shadowRoot;
7931
+ if (_isDocumentFragment(sr)) stack.push({
7932
+ node: null,
7933
+ shadow: sr
7934
+ }, {
7935
+ node: sr,
7936
+ shadow: null
7937
+ });
7805
7938
  }
7806
7939
  }
7807
7940
  };
@@ -7820,35 +7953,48 @@ function createDOMPurify() {
7820
7953
  if (!DOMPurify.isSupported) return dirty;
7821
7954
  if (!SET_CONFIG) _parseConfig(cfg);
7822
7955
  DOMPurify.removed = [];
7823
- if (typeof dirty === "string") IN_PLACE = false;
7824
- if (IN_PLACE) {
7956
+ const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
7957
+ if (inPlace) {
7825
7958
  const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
7826
7959
  if (typeof nn === "string") {
7827
7960
  const tagName = transformCaseFunc(nn);
7828
7961
  if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
7829
7962
  }
7830
7963
  if (_isClobbered(dirty)) throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
7831
- _sanitizeAttachedShadowRoots2(dirty);
7964
+ try {
7965
+ _sanitizeAttachedShadowRoots(dirty);
7966
+ } catch (error) {
7967
+ _neutralizeRoot(dirty);
7968
+ throw error;
7969
+ }
7832
7970
  } else if (_isNode(dirty)) {
7833
7971
  body = _initDocument("<!---->");
7834
7972
  importedNode = body.ownerDocument.importNode(dirty, true);
7835
7973
  if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
7836
7974
  else if (importedNode.nodeName === "HTML") body = importedNode;
7837
7975
  else body.appendChild(importedNode);
7838
- _sanitizeAttachedShadowRoots2(importedNode);
7976
+ _sanitizeAttachedShadowRoots(importedNode);
7839
7977
  } else {
7840
7978
  if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
7841
7979
  body = _initDocument(dirty);
7842
7980
  if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
7843
7981
  }
7844
7982
  if (body && FORCE_BODY) _forceRemove(body.firstChild);
7845
- const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
7846
- while (currentNode = nodeIterator.nextNode()) {
7847
- _sanitizeElements(currentNode);
7848
- _sanitizeAttributes(currentNode);
7849
- if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
7983
+ const nodeIterator = _createNodeIterator(inPlace ? dirty : body);
7984
+ try {
7985
+ while (currentNode = nodeIterator.nextNode()) {
7986
+ _sanitizeElements(currentNode);
7987
+ _sanitizeAttributes(currentNode);
7988
+ if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
7989
+ }
7990
+ } catch (error) {
7991
+ if (inPlace) _neutralizeRoot(dirty);
7992
+ throw error;
7850
7993
  }
7851
- if (IN_PLACE) {
7994
+ if (inPlace) {
7995
+ arrayForEach(DOMPurify.removed, (entry) => {
7996
+ if (entry.element) _neutralizeSubtree(entry.element);
7997
+ });
7852
7998
  if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
7853
7999
  return dirty;
7854
8000
  }
@@ -7879,6 +8025,8 @@ function createDOMPurify() {
7879
8025
  DOMPurify.clearConfig = function() {
7880
8026
  CONFIG = null;
7881
8027
  SET_CONFIG = false;
8028
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
8029
+ emptyHTML = "";
7882
8030
  };
7883
8031
  DOMPurify.isValidAttribute = function(tag, attr, value) {
7884
8032
  if (!CONFIG) _parseConfig({});