DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing values to be safe to use in the different DOM contexts. Any questions concerning DomSanitizer package
Questions tagged [angular-dom-sanitizer]
120 questions
1
vote
1 answer
Angular 4 sanitize pipe strips custom components
I have a modal service that takes an object as a parameter like this:
modal = {
title: My Modal,
body: template
}
This gets passed to a modal component that holds the template for the modal (using bootstrap 4).

g_madden
- 11
- 1
1
vote
1 answer
How to use DomSanitizer inside a function
Hi I´m triyin to build a function to be reusable, and sanitize some content, but I don´t know hoe to call DomSanitizer it allways give me the error that is and abstract class.
Here is my function:
export function PostFormat(post){
let sanitizer:…

efirvida
- 4,592
- 3
- 42
- 68
1
vote
2 answers
bypasssecuritytrust from DomSanitizer not working (Angular 2)
My problem is the following, I get as a response from a service an entire HTML page that I should display back t the user. Now this is an issue for Angular since it thinks I might be a victim of cross site scripting if I do that. The source I get…
user6183573
1
vote
1 answer
Angular2 DomSanitizer issue
I am trying to use background-image inline for my *ngFor list items.
Im my Component Class I declare a variable which stores a common part of my images URL (say, it's http://storage.com/) and also unique parts of URLs of the images as this.image…

Alexandr Belov
- 1,804
- 9
- 30
- 43
0
votes
0 answers
Angular sanitize and HTML highlighting of special char
I'm currently trying to combine Angular DomSanitizer.sanitize function with an "home made" Search highlighting.
Given that I have a data which could be entered by users (like most of web site in this world) named dataEnterredByUser
I want to be able…

GTH
- 11
- 3
0
votes
1 answer
Can't Display the image after sanitizing it
I am trying to Make an image file display on the Html of ionic(angular) component.
The image file is fetched from the device itself and converted to file format for processing.
I am using ionic(angular) framework to build an social media platform…

Harsh Sharma
- 1
- 1
- 3
0
votes
0 answers
Iframe throws 404 error when initial load in angular 8
When I tried to load pdf in iframe, initialy it loads 404 error page and then loads the pdf file.
I thought, it would be url issue when iframe loads.
So I have tried with *ngIf. So once url this.sanitizer.bypassSecurityTrustResourceUrl will be ready…

klmuralimohan
- 861
- 4
- 23
- 44
0
votes
0 answers
Angular DOM sanitizer: How to keep accents in message input?
I am using DomSanitizer to search if there are any scripts inside an message(a formgroup of the site). The scripting part works, but if I use any accent inside the message, it get's changed . How to solve this?
this.formGroup.value.message=…

Guilherme
- 1
- 1
0
votes
0 answers
Angular DomSanitizer replacing new line characters on textarea fields
Is Angular's DomSanitizer just a glorified text-replacer? If it is, I'd like to know if it's feasible to implement my own sanitizer, because the Angular one is replacing special characters like "<" with <, when I think it should just replace "<"…

the_overflowing_stack
- 57
- 1
- 6
0
votes
0 answers
Rendering template that is provided by server
Our project architect decided that they want to have html-Templates for a guide book for our users persisted in our database for version management and other reasons.
Now they expect me to fetch those templates whenever a user opens the guide book…

Chund
- 355
- 2
- 15
0
votes
1 answer
How to use a DomSanitizer inside a unit test, if the component does not inject it?
I have a simple component, which does not inject the DomSanitizer. Let's say it is
export class ExampleComponent {
@Input()
public safeHtml: SafeHtml | undefined;
}
How can I use the DomSanitizer inside a unit test? I've tried providing…

MojioMS
- 1,583
- 4
- 17
- 42
0
votes
0 answers
Angular - Read HTML and Style from text and render it
Let's say I have a strings:
data =
"
- text1
- text2…

Ahmad Mansouri
- 71
- 1
- 6
0
votes
0 answers
Angular - safeHTML when added to innerHTML gets stripped if content is too long.Specifically when added style tag
I am having content which has a style tag with huge css code. To make it work in innerHTML I am using DomSanitizer with bypassSecurityTrustHtml method to generate safeHtml.
But when I am trying to add same safeHTML to paragraph with innerHTML it is…

Roshan Joshi
- 13
- 5
0
votes
1 answer
How do I resolve sanitizing unsafe URL value with blob value?
I'm having this sanitize URL error in Angular, I've seen many solutions, but I've not been able to use them in my scenario, that's why I'm asking the question.
Here is my function:
@Input()
maxFileSize: number = 1000000;
public…

Code Haven
- 51
- 6
0
votes
0 answers
How to prevent jasmine test from failing due to "WARNING: sanitizing HTML stripped some content, see https://g.co/ng/security#xss thrown"
I'm writing unit tests for a component that uses [innerHTML] to display content from backend. In the browser when the component is loaded, this warning
"WARNING: sanitizing HTML stripped some content, see https://g.co/ng/security#xss thrown" is…