Add SVG support to DomSanitizer
See original GitHub issueπ feature request
Relevant Package
This feature request is for @angular/coreDescription
There should be a way to sanitize SVG code, right now even `<svg></svg>` is getting stripped to nothing by DomSanitizer.sanitize in HTML context. Perhaps there could be separate SVG SecurityContext added, but there should be a way to use SVG via source string in Angular.Describe the solution youβd like
DomSanitizer should be able to sanitize SVG.Describe alternatives youβve considered
Creating your own sanitizer, probably using DOMPurifyIssue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Angular 2, DomSanitizer, bypassSecurityTrustHtml, SVG
My issue wasn't what OP stated but I got what I came looking for. Many solutions suggested to use @Pipe and adding DOMSanitizer...
Read more >How to use custom svg icon in Angular material design
Next, open app.components.ts and include MatIconRegistry and DomSanitizer. import { MatIconRegistry } ... Import SVG as a file to your Angular Material app....
Read more >DomSanitizer
DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing values to be safe to use in the different DOM contexts.
Read more >How To Use Custom SVG Icons in Angular Material
Then, you will use the component to support a cus⦠... "@angular/material/icon"; import { DomSanitizer } from "@angular/platform-browser";.
Read more >How to: Use Angular Material's Mat-Icon with local SVG ...
So lets add the DomSanitizer and fix this issue. //app.component.ts // Second Example - with the DomSanitizer @Component({ selector: 'app-root',Β ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, I ended up creating my own sanitizer that delegates work to DOMPurify, works pretty good: https://github.com/TinkoffCreditSystems/ng-dompurify Might be what you need, but your suggestion is also interesting.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.