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

Function _executableFindings

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

Source from the content-addressed store, hash-verified

9040 /* Collect anything executable reachable from a serialized string, walking
9041 into <template>.content and any activated shadowRoot. */
9042 const _executableFindings = function (root) {
9043 const findings = [];
9044 const visit = (node) => {
9045 if (!node) return;
9046 if (node.nodeType === 1) {
9047 const tag = node.tagName ? node.tagName.toLowerCase() : '';
9048 for (const name of node.getAttributeNames()) {
9049 if (/^on/i.test(name)) findings.push(`${tag}@${name}`);
9050 if (
9051 (name === 'href' || name === 'src' || name === 'xlink:href') &&
9052 /^\s*(?:java|vb)script:/i.test(node.getAttribute(name) || '')
9053 ) {
9054 findings.push(`${tag}@${name}=js`);
9055 }
9056 }
9057 if (tag === 'script') findings.push('script');
9058 if (node.shadowRoot) visit(node.shadowRoot);
9059 if (tag === 'template' && node.content) visit(node.content);
9060 }
9061 for (const child of node.childNodes) visit(child);
9062 };
9063 visit(root);
9064 return findings;
9065 };
9066 const _findingsFromHTML = function (html) {
9067 const holder = document.createElement('div');
9068 holder.innerHTML = html;

Callers 2

_findingsFromHTMLFunction · 0.85
test-suite.jsFile · 0.85

Calls 1

visitFunction · 0.85

Tested by

no test coverage detected