Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
First, thank you for your library as it helped me to quickly ship an app while I was still learning Angular.
Now, you dont want to use the
bypassSecurityTrustHtml
method to bind some HTML (especially since it's just for<br>
tags), as you bypass the built-in Angular sanitizer, and add an avoidable vulnerability to XSS attacks.You should use the
sanitize
method with the right security context. Here are the API references :https://angular.io/api/platform-browser/DomSanitizer#sanitize
https://angular.io/api/core/SecurityContext
Better than that, thanks to Angular, binding HTML with the
[innerHtml]
property automatically sanitizes the HTML for you with the right security context. So you don't even need to sanitize beforehand.I still kept the sanitization as a optionnal parameter, if you want to use the
transform
method elsewhere.In the end, I strongly recommend you and the users of your library to patch this security issue. 👍