-
-
Notifications
You must be signed in to change notification settings - Fork 822
Closed
Description
Background & Context
We use DOMPurify 2.3.4 and need to support webOS 1.2/2.0
They use some older WebKit engines that do not seem to support the text/html type in DOMParser (returns null).
Then DOMPurify goes to the createDocument workaround.
It creates a document with documentElement = 'template'.
In the last step it looks for body, but it is not there (neither is html) - the root is template.
This can be reproduced in Chrome:
const doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'template', null);
doc.documentElement.innerHTML = '<center>test</center>';
console.debug(doc.documentElement.getElementsByTagName('body')); // -> HTMLCollection []It probably need to look for template if that workaround was used, or just skip this section.
Lines 796 to 802 in 9172631
| /* Work on whole document or just its body */ | |
| if (NAMESPACE === HTML_NAMESPACE) { | |
| return getElementsByTagName.call( | |
| doc, | |
| WHOLE_DOCUMENT ? 'html' : 'body' | |
| )[0]; | |
| } |
Bug
Input
'<center>test</center>'
Given output
'' (empty string)
Expected output
'<center>test</center>'
Metadata
Metadata
Assignees
Labels
No labels