Revert "93963: Use sanitize-html instead of isomorphic-dompurifier"

This reverts commit a789cb0960e966d19d86dfc67f274c6b1751ec32.
This commit is contained in:
Samuel Cambien
2022-09-27 17:38:31 +02:00
parent 8800b1e0e8
commit 42608c6b09

View File

@@ -1,6 +1,6 @@
import { Inject, InjectionToken, Pipe, PipeTransform } from '@angular/core';
import MarkdownIt from 'markdown-it';
import * as sanitizeHtml from 'sanitize-html';
import * as DOMPurify from 'isomorphic-dompurify';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { environment } from '../../../environments/environment';
@@ -46,38 +46,6 @@ export class MarkdownPipe implements PipeTransform {
if (environment.markdown.mathjax) {
md.use(await this.mathjax);
}
return this.sanitizer.bypassSecurityTrustHtml(
sanitizeHtml(md.render(value), {
// sanitize-html doesn't let through SVG by default, so we extend its allowlists to cover MathJax SVG
allowedTags: [
...sanitizeHtml.defaults.allowedTags,
'mjx-container', 'svg', 'g', 'path', 'rect', 'text'
],
allowedAttributes: {
...sanitizeHtml.defaults.allowedAttributes,
'mjx-container': [
'class', 'style', 'jax'
],
svg: [
'xmlns', 'viewBox', 'style', 'width', 'height', 'role', 'focusable', 'alt', 'aria-label'
],
g: [
'data-mml-node', 'style', 'stroke', 'fill', 'stroke-width', 'transform'
],
path: [
'd', 'style', 'transform'
],
rect: [
'width', 'height', 'x', 'y', 'transform', 'style'
],
text: [
'transform', 'font-size'
]
},
parser: {
lowerCaseAttributeNames: false,
},
})
);
return this.sanitizer.bypassSecurityTrustHtml(DOMPurify.sanitize(md.render(value)));
}
}