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

Function _createNodeIterator

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

Source from the content-addressed store, hash-verified

1513 * @return The created NodeIterator
1514 */
1515 const _createNodeIterator = function (root: Node): NodeIterator {
1516 /* Read ownerDocument through the cached Node.prototype getter, never the
1517 direct property. HTMLFormElement has [LegacyOverrideBuiltIns], so a
1518 clobbering child (<input name="ownerDocument"> or a form-associated
1519 external input) shadows the prototype getter and makes a direct read
1520 return that <input>. createNodeIterator.call(<input>, ...) then throws
1521 "Illegal invocation", and on the IN_PLACE path that throw lands before
1522 the walk's fail-closed barrier - leaving the caller's live tree, with
1523 any already-armed handler in it, un-neutralized. The cached getter
1524 returns the real Document regardless of the clobber. */
1525 const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
1526 return createNodeIterator.call(
1527 doc || root,
1528 root,
1529 // eslint-disable-next-line no-bitwise
1530 NodeFilter.SHOW_ELEMENT |
1531 NodeFilter.SHOW_COMMENT |
1532 NodeFilter.SHOW_TEXT |
1533 NodeFilter.SHOW_PROCESSING_INSTRUCTION |
1534 NodeFilter.SHOW_CDATA_SECTION,
1535 null
1536 );
1537 };
1538
1539 /**
1540 * 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