refactor(core): make HTML sanitizer return TrustedHTML (#39218)

Make Angular's HTML sanitizer return a TrustedHTML, as its output is
trusted not to cause XSS vulnerabilities when used in a context where a
browser may parse and evaluate HTML. Also update tests to reflect the
new behaviour.

PR Close #39218
This commit is contained in:
Bjarki
2020-10-10 00:27:29 +00:00
committed by Andrew Kushnir
parent e8d47c2d41
commit 9ec2bad4dc
4 changed files with 56 additions and 51 deletions

View File

@ -162,7 +162,7 @@ export class DomSanitizerImpl extends DomSanitizer {
if (allowSanitizationBypassOrThrow(value, BypassType.Html)) {
return unwrapSafeValue(value);
}
return _sanitizeHtml(this._doc, String(value));
return _sanitizeHtml(this._doc, String(value)).toString();
case SecurityContext.STYLE:
if (allowSanitizationBypassOrThrow(value, BypassType.Style)) {
return unwrapSafeValue(value);