cure53 / DOMPurify

DOMPurify - a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. DOMPurify works with a secure default, but offers a lot of configurability and hooks. Demo:
https://cure53.de/purify
Other
13.67k stars 698 forks source link

Added support for the Angular compiler. #990

Closed jeroen1602 closed 1 week ago

jeroen1602 commented 1 week ago

Summary

The Angular compiler looks for the main field using a few fields in the package.json. The order it uses is:

The first entry the Angular compiler would find before this change was the 'browser' entry point. This is however compiled as an umd and Angular is looking for an esm so it would complain (it would still work though). Adding es2020 as an entry point fixes this problem.

Fixes #869

Background & Context

Tasks

  1. Create an Angular application
  2. Add this package as a dependency npm install --save ./path/to/project
  3. Import DOMPurify in the AppComponent and just sanitize some string in the ngOnInit function
  4. Run npm run build to build this application and see that the warning about common js modules is resolved.

Dependencies

jeroen1602 commented 1 week ago

I don't known how I did it but somehow I changed more files than I wanted, will try to amend this commit.

Edit: Never mind it is a pre-commit step so it's probably meant to do this.

cure53 commented 1 week ago

Most excellent, thank you :)