Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different result between Happy DOM and JSDOM when using DOM.sanitize() #1403

Open
capricorn86 opened this issue Apr 12, 2024 · 1 comment
Open
Labels
bug Something isn't working high priority

Comments

@capricorn86
Copy link
Owner

// dompurify.js on Node.js 21.6.1
 
import createDOMPurify from 'dompurify'; // 3.0.8
import { Window } from 'happy-dom'; // 13.3.1
import { JSDOM } from 'jsdom'; // 24.0.0
 
const input = `<script>"HELLO"</script><body onload="document.write('hello')"><img onload="document.write('hey')"><script>document.write('hello');</script>`;
 
{
  const window = new Window();
  const DOMPurify = createDOMPurify(window);
  const clean = DOMPurify.sanitize(input);
  console.log('happy', clean);
}
 
{
  const window = new JSDOM('').window;
  const DOMPurify = createDOMPurify(window);
  const clean = DOMPurify.sanitize(input);
  console.log('jsdom', clean);
}
@capricorn86 capricorn86 added the bug Something isn't working label Apr 12, 2024
@capricorn86
Copy link
Owner Author

Related to #1374 and #1265

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

1 participant