Skip to content

createHTML in conjunction with XML documents is a bit broken #612

Open

Description

@noamr

See #569 for initial discussion

Currentlly, there is no way for a policy to tell whether the target document for an insertion is HTML.
This means that calling innerHTML on an XML document would trigger the default createHTML callback.
When this is an XHTML active document, the policy can check the global document's type.

However, inactive documents share the active document's default policy. e.g.:

const xml_document = document.implementation.createDocument(...);

 // This will invoke the active document's default policy
xml_document.firstChild.innerHTML = "...";

or

const xhr = new XMLHttpRequest();
xhr.addEventListener("load", () => {
   const xml_doc = xhr.response.document;
   // This will invoke the active document's default policy
   xml_doc.firstChild.innerHTML = "...";
});
xhr.open("GET", "doc.xml");
xhr.send();

Since these use cases are a bit funky to begin with and already generally broken, it might be better to throw an error in those occasions (probably when trying to apply the resulting TrustedHTML, or before consulting with the policy)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions