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

Function _executableFindings

test/test-suite.js:7825–7848  ·  view source on GitHub ↗
(root)

Source from the content-addressed store, hash-verified

7823 /* Collect anything executable reachable from a serialized string, walking
7824 into <template>.content and any activated shadowRoot. */
7825 const _executableFindings = function (root) {
7826 const findings = [];
7827 const visit = (node) => {
7828 if (!node) return;
7829 if (node.nodeType === 1) {
7830 const tag = node.tagName ? node.tagName.toLowerCase() : '';
7831 for (const name of node.getAttributeNames()) {
7832 if (/^on/i.test(name)) findings.push(`${tag}@${name}`);
7833 if (
7834 (name === 'href' || name === 'src' || name === 'xlink:href') &&
7835 /^\s*(?:java|vb)script:/i.test(node.getAttribute(name) || '')
7836 ) {
7837 findings.push(`${tag}@${name}=js`);
7838 }
7839 }
7840 if (tag === 'script') findings.push('script');
7841 if (node.shadowRoot) visit(node.shadowRoot);
7842 if (tag === 'template' && node.content) visit(node.content);
7843 }
7844 for (const child of node.childNodes) visit(child);
7845 };
7846 visit(root);
7847 return findings;
7848 };
7849 const _findingsFromHTML = function (html) {
7850 const holder = document.createElement('div');
7851 holder.innerHTML = html;

Callers 2

_findingsFromHTMLFunction · 0.85
test-suite.jsFile · 0.85

Calls 1

visitFunction · 0.85

Tested by

no test coverage detected