I am trying to sanitize an user-submitted template by using DOMPurify. This template is using the mustache-syntax to embed variables etc. The sanitizing itself works without issue, but Mustache-Sections are being moved to different parts within the template and DOMPurify seems to try to fix the HTML structure itself.
I am assuming this "autofix" is messing with the template. Is there a way to prevent this?
The following code is being used for the sanitizing:
DOMPurify.sanitize(model.html_template);
Template before sanitizing:
<table>
<tr>
<td>{{value1}}</td>
</tr>
{{#section}}
<tr>
<td>{{value2}}</td>
</tr>
{{/section}}
</table>
Template after sanitizing:
{{#section}}
{{/section}}
<table>
<tbody>
<tr>
<td>{{value1}}</td>
</tr>
<tr>
<td>{{value2}}</td>
</tr>
</tbody>
</table>