diff options
| author | Shyam Sunder | 2020-06-23 13:24:59 -0400 |
|---|---|---|
| committer | Shyam Sunder | 2020-06-23 13:24:59 -0400 |
| commit | 0137cf383a81e0a2a0f5db7c2ded4b4a55c5e2fc (patch) | |
| tree | 2cbd181ff7e8818f99e56789b4215962cfb25aca /client/js | |
| parent | 342ca9ccba57f5d758baea1a4c67168c3175745d (diff) | |
client/markdown: use DOMPurify over marked.js sanitizer
See markedjs/marked#1232
Diffstat (limited to 'client/js')
| -rw-r--r-- | client/js/util/markdown.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/client/js/util/markdown.js b/client/js/util/markdown.js index 792c938..22cdae5 100644 --- a/client/js/util/markdown.js +++ b/client/js/util/markdown.js @@ -1,6 +1,7 @@ "use strict"; const marked = require("marked"); +const DOMPurify = require("dompurify"); class BaseMarkdownWrapper { preprocess(text) { @@ -158,7 +159,6 @@ function formatMarkdown(text) { const options = { renderer: renderer, breaks: true, - sanitize: true, smartypants: true, }; let wrappers = [ @@ -179,7 +179,7 @@ function formatMarkdown(text) { for (let wrapper of wrappers) { text = wrapper.postprocess(text); } - return text; + return DOMPurify.sanitize(text); } function formatInlineMarkdown(text) { @@ -187,7 +187,6 @@ function formatInlineMarkdown(text) { const options = { renderer: renderer, breaks: true, - sanitize: true, smartypants: true, }; let wrappers = [ @@ -206,7 +205,7 @@ function formatInlineMarkdown(text) { for (let wrapper of wrappers) { text = wrapper.postprocess(text); } - return text; + return DOMPurify.sanitize(text); } module.exports = { |