Skip to content

Questions About _isClobbered #585

@GrantGryczan

Description

@GrantGryczan

Out of curiosity, could you give an example/explanation of some input that makes this condition return true?

DOMPurify/src/purify.js

Lines 793 to 802 in dbf7a34

if (
typeof elm.nodeName !== 'string' ||
typeof elm.textContent !== 'string' ||
typeof elm.removeChild !== 'function' ||
!(elm.attributes instanceof NamedNodeMap) ||
typeof elm.removeAttribute !== 'function' ||
typeof elm.setAttribute !== 'function' ||
typeof elm.namespaceURI !== 'string' ||
typeof elm.insertBefore !== 'function'
) {

Also, why does this still run when the SANITIZE_DOM config option is false? I was under the impression that setting SANITIZE_DOM to false disables any clobbering-related checks. Is that not the purpose of SANITIZE_DOM? If not, what's the purpose?

Lastly, is it strictly necessary to get the value of elm.textContent in order to ensure it isn't clobbered? The textContent getter is really relatively slow. For large node trees, sanitization can be very noticeably slow just because of that one check (which I know because I profiled it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions