MCPcopy Create free account
hub / github.com/angular/angular / ɵɵsanitizeHtml

Function ɵɵsanitizeHtml

packages/core/src/sanitization/sanitization.ts:51–72  ·  view source on GitHub ↗
(
  unsafeHtml: any,
  tagName?: string,
  propName?: string,
)

Source from the content-addressed store, hash-verified

49 * @codeGenApi
50 */
51export function ɵɵsanitizeHtml(
52 unsafeHtml: any,
53 tagName?: string,
54 propName?: string,
55): TrustedHTML | string {
56 if (
57 tagName !== undefined &&
58 propName !== undefined &&
59 getSecurityContext(tagName, propName) !== SecurityContext.HTML
60 ) {
61 return unsafeHtml;
62 }
63
64 const sanitizer = getSanitizer();
65 if (sanitizer) {
66 return trustedHTMLFromStringBypass(sanitizer.sanitize(SecurityContext.HTML, unsafeHtml) || '');
67 }
68 if (allowSanitizationBypassAndThrow(unsafeHtml, BypassType.Html)) {
69 return trustedHTMLFromStringBypass(unwrapSafeValue(unsafeHtml));
70 }
71 return _sanitizeHtml(getDocument(), renderStringify(unsafeHtml));
72}
73
74/**
75 * A `style` sanitizer which converts untrusted `style` **string** into trusted string by removing

Callers 1

Calls 9

unwrapSafeValueFunction · 0.90
_sanitizeHtmlFunction · 0.90
getDocumentFunction · 0.90
renderStringifyFunction · 0.90
getSecurityContextFunction · 0.85
getSanitizerFunction · 0.85
sanitizeMethod · 0.45

Tested by

no test coverage detected