forked from primefaces/primeng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made safeHtml standalone and used in all [innerHTML] bindings to stop…
… injection
- Loading branch information
1 parent
2929519
commit a4116bd
Showing
15 changed files
with
79 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { isPlatformBrowser } from '@angular/common'; | ||
import { | ||
Inject, PLATFORM_ID, | ||
Pipe, | ||
PipeTransform, | ||
SecurityContext | ||
} from '@angular/core'; | ||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; | ||
|
||
|
||
@Pipe({ | ||
name: 'safeHtml', | ||
standalone: true | ||
}) | ||
export class SafeHtmlPipe implements PipeTransform { | ||
constructor(@Inject(PLATFORM_ID) private readonly platformId: any, private readonly domSanitizer: DomSanitizer) { } | ||
|
||
public transform(value: string): SafeHtml { | ||
if (!value || !isPlatformBrowser(this.platformId)) { | ||
return value; | ||
} | ||
|
||
const sanitizedValue = this.domSanitizer.sanitize(SecurityContext.HTML ,value); | ||
return this.domSanitizer.bypassSecurityTrustHtml(sanitizedValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.