question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add SVG support to DomSanitizer

See original GitHub issue

πŸš€ feature request

Relevant Package

This feature request is for @angular/core

Description

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 DOMPurify

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
waterpleacommented, Apr 16, 2020

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.

0reactions
angular-automatic-lock-bot[bot]commented, Jul 8, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found