Closed francoisjacquet closed 1 year ago
Hmmm, good question! Can you set a break-point in sanitize()
and check where the string content gets voided?
If it's really our bug, we'd love to fix it very quickly. But we need your help with the debugging.
We had a closer look and indeed the wkhtmltopdf
JavaScript support is a bit rusty, latest versions of DOMPurify do not work properly with the old engine that is being used :sweat_smile:
However, slightly older versions still work:
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.1/purify.js"></script>
<script>
var html = "<h1>GOODBYE</h1>";
document.write(DOMPurify.sanitize(html));
</script>
<h2>Hello</h2>
and
$ wkhtmltopdf --debug-javascript --javascript-delay 500 --enable-javascript --no-stop-slow-scripts basic-demo.html dompurify.pdf
work as expected, hope that helps :smile:
Hello,
I have been trying to use DOMPurify with wkhtmltopdf.
The
DOMPurify.isSupported
property is set to true.But the
sanitize()
function returns an empty string.The same code is OK inside the browser and returns HTML.
I know wkhtmltopdf uses QtWebkit, any hints why we have this behavior?
Note: I have tried with DOMPurify 3.0.3 and the DOMPurify.sanitize` seems to trigger an error as I can't seem to get any further.