Skip to content

Commit 2d2f8ff

Browse files
authored
Merge commit from fork
fixed: sanitize rendered HTML
2 parents f16f2fd + 9c038ec commit 2d2f8ff

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/markd.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const md = require('markdown-it')
88
const confluencer = require('confluencer')
99
const { newError, contentSecurityPolicy } = require('./utils.js')
1010

11+
const createDOMPurify = require('dompurify')
12+
const { JSDOM } = require('jsdom')
13+
const window = (new JSDOM('')).window
14+
const DOMPurify = createDOMPurify(window)
15+
1116
const tmpl = fs.readFileSync(path.resolve(__dirname, 'pages', 'template.html'))
1217

1318
const markedppP = promisify(markedpp)
@@ -39,6 +44,7 @@ async function markdown(title, data, config) {
3944
config.markdownItPlugins(mdIt)
4045

4146
let _data = mdIt.render(data)
47+
_data = DOMPurify.sanitize(_data, { USE_PROFILES: { html: true } })
4248

4349
if (config.confluencer) {
4450
const confluenceHtml =

0 commit comments

Comments
 (0)