Closed lucamerighi closed 3 months ago
That is indeed expected behavior, as the parser rejects non-wellformed XML and simply refuses to do anything with it.
Once you change the type to text/xhtml
it works again.
With that parser it works, but void tags are kept as is. Is there some option to convert tags like <br>
into their self closed <br />
form?
Not sure, maybe by using a hook or a different parser. That would be out-of-scope for DOMPurify but can likely be achieved with a hook.
Closing this for now as we don't have anything to fix on our end :slightly_smiling_face:
Background & Context
Porting of this isomorphic-dompurify issue as it's happening with vanilla dompurify as well
Bug
DOMPurify.sanitize
returns an empty string when ran on HTML strings containing void elements when application/xhtml+xml is set as parser media type.Dompurify version: 3.1.0 JSDOM version: 24.0.0
Input
Given output
Empty string
Expected output
Same outcome for other void elements, such as meta or link tags. Removing the
<br>
in the provided input gives the correct output