SafeValue must use [property] getting appended to url in iframe src (Angular 14)

159 views Asked by At

I am binding a link in iframe src as below

public resultLink: SafeResourceUrl;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             

this.resultLink = this.domSanitizer.bypassSecurityTrustResourceUrl(searchResult.pageUrl);

<iframe title="Finder Results" [src]="resultLink"></iframe>

But I am getting following output

<iframe title="Finder Results"  src="SafeValue must use [property]=binding: www.testurl.com (See https://g.co/ng/security#xss)"></iframe>

How can we fix this?

1

There are 1 answers

0
Wandrille On

It could related to safeUrl:

<iframe title="Finder Results" [src]="resultLink | safeUrl"></iframe>