Kroc/DOMTemplate

Detect source type (HTML / XML)

Closed this issue · 0 comments

Kroc commented

In order to avoid XML being broken by the HTML filtering, we need to detect (or provide via parameter) whether the input text is HTML or XML. We can check for a DOCTYPE vs. an XML prolog.

Note that this also needs to be done for the inserting HTML function that appends a DOM fragment. This is more tricky because the fragment won't include a DOCTYPE / prolog. -- we probably need to remember the original type detected and re-use it there.

This can be expanded in the future to detect between XHTML / HTML4 / HTML5 & XML for more specific filtering (entities, UTF-8 &c.)