MCPcopy Create free account
hub / github.com/cure53/DOMPurify / _createNodeIterator

Function _createNodeIterator

src/purify.ts:1659–1681  ·  view source on GitHub ↗
(root: Node)

Source from the content-addressed store, hash-verified

1657 * @return The created NodeIterator
1658 */
1659 const _createNodeIterator = function (root: Node): NodeIterator {
1660 /* Read ownerDocument through the cached Node.prototype getter, never the
1661 direct property. HTMLFormElement has [LegacyOverrideBuiltIns], so a
1662 clobbering child (<input name="ownerDocument"> or a form-associated
1663 external input) shadows the prototype getter and makes a direct read
1664 return that <input>. createNodeIterator.call(<input>, ...) then throws
1665 "Illegal invocation", and on the IN_PLACE path that throw lands before
1666 the walk's fail-closed barrier - leaving the caller's live tree, with
1667 any already-armed handler in it, un-neutralized. The cached getter
1668 returns the real Document regardless of the clobber. */
1669 const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
1670 return createNodeIterator.call(
1671 doc || root,
1672 root,
1673 // eslint-disable-next-line no-bitwise
1674 NodeFilter.SHOW_ELEMENT |
1675 NodeFilter.SHOW_COMMENT |
1676 NodeFilter.SHOW_TEXT |
1677 NodeFilter.SHOW_PROCESSING_INSTRUCTION |
1678 NodeFilter.SHOW_CDATA_SECTION,
1679 null
1680 );
1681 };
1682
1683 /**
1684 * Replace template expression syntax (mustache, ERB, template

Callers 2

_sanitizeShadowDOMFunction · 0.85
createDOMPurifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected