Skip to content

Commit 42608c6

Browse files
committed
Revert "93963: Use sanitize-html instead of isomorphic-dompurifier"
This reverts commit a789cb0.
1 parent 8800b1e commit 42608c6

1 file changed

Lines changed: 2 additions & 34 deletions

File tree

src/app/shared/utils/markdown.pipe.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Inject, InjectionToken, Pipe, PipeTransform } from '@angular/core';
22
import MarkdownIt from 'markdown-it';
3-
import * as sanitizeHtml from 'sanitize-html';
3+
import * as DOMPurify from 'isomorphic-dompurify';
44
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
55
import { environment } from '../../../environments/environment';
66

@@ -46,38 +46,6 @@ export class MarkdownPipe implements PipeTransform {
4646
if (environment.markdown.mathjax) {
4747
md.use(await this.mathjax);
4848
}
49-
return this.sanitizer.bypassSecurityTrustHtml(
50-
sanitizeHtml(md.render(value), {
51-
// sanitize-html doesn't let through SVG by default, so we extend its allowlists to cover MathJax SVG
52-
allowedTags: [
53-
...sanitizeHtml.defaults.allowedTags,
54-
'mjx-container', 'svg', 'g', 'path', 'rect', 'text'
55-
],
56-
allowedAttributes: {
57-
...sanitizeHtml.defaults.allowedAttributes,
58-
'mjx-container': [
59-
'class', 'style', 'jax'
60-
],
61-
svg: [
62-
'xmlns', 'viewBox', 'style', 'width', 'height', 'role', 'focusable', 'alt', 'aria-label'
63-
],
64-
g: [
65-
'data-mml-node', 'style', 'stroke', 'fill', 'stroke-width', 'transform'
66-
],
67-
path: [
68-
'd', 'style', 'transform'
69-
],
70-
rect: [
71-
'width', 'height', 'x', 'y', 'transform', 'style'
72-
],
73-
text: [
74-
'transform', 'font-size'
75-
]
76-
},
77-
parser: {
78-
lowerCaseAttributeNames: false,
79-
},
80-
})
81-
);
49+
return this.sanitizer.bypassSecurityTrustHtml(DOMPurify.sanitize(md.render(value)));
8250
}
8351
}

0 commit comments

Comments
 (0)