NgxSafePipes
This library provide convenient pipes to bypass Angular built-in sanitization and get rid off the unsafe value used in a ... context
.
Installation
Install with npm :
npm i @it-era/ngx-safe-pipes
And add the NgxSafePipesModule
into the imports array of your module (containing the template to fix) :
import { NgxSafePipesModule } from '@it-era/ngx-safe-pipes';
@NgModule({
imports: [
NgxSafePipesModule,
]
})
export class YourModule { }
List of pipes
SafeHtml
Usage :
<div [InnerHTML]="trustedHtml | safeHtml"></div>
SafeResourceUrl
Usage :
<iframe [attr.src]="trustedSrc | safeResourceUrl"></iframe>
SafeScript
Usage :
<script [attr.src]="trustedSrc | safeScript"></script>
SafeStyle
Usage :
<style [attr.src]="trustedSrc | safeStyle"></style>
SafeUrl
Usage :
<a [attr.href]="trustedHref | safeUrl"></a>
WARNING: calling thoses methods with untrusted user data exposes your application to XSS security risks!