Commit ec24ac27 authored by NGPixel's avatar NGPixel

fix: sanitize markdown preview on content change

parent b2931471
...@@ -184,6 +184,7 @@ import _ from 'lodash' ...@@ -184,6 +184,7 @@ import _ from 'lodash'
import { get, sync } from 'vuex-pathify' import { get, sync } from 'vuex-pathify'
import markdownHelp from './markdown/help.vue' import markdownHelp from './markdown/help.vue'
import gql from 'graphql-tag' import gql from 'graphql-tag'
import DOMPurify from 'dompurify'
/* global siteConfig, siteLangs */ /* global siteConfig, siteLangs */
...@@ -395,7 +396,7 @@ export default { ...@@ -395,7 +396,7 @@ export default {
onCmInput: _.debounce(function (newContent) { onCmInput: _.debounce(function (newContent) {
linesMap = [] linesMap = []
this.$store.set('editor/content', newContent) this.$store.set('editor/content', newContent)
this.previewHTML = md.render(newContent) this.previewHTML = DOMPurify.sanitize(md.render(newContent))
this.$nextTick(() => { this.$nextTick(() => {
this.renderMermaidDiagrams() this.renderMermaidDiagrams()
Prism.highlightAllUnder(this.$refs.editorPreview) Prism.highlightAllUnder(this.$refs.editorPreview)
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
"dependency-graph": "0.9.0", "dependency-graph": "0.9.0",
"diff": "4.0.2", "diff": "4.0.2",
"diff2html": "3.1.6", "diff2html": "3.1.6",
"dompurify": "2.0.10",
"dotize": "0.3.0", "dotize": "0.3.0",
"elasticsearch6": "npm:@elastic/elasticsearch@6", "elasticsearch6": "npm:@elastic/elasticsearch@6",
"elasticsearch7": "npm:@elastic/elasticsearch@7", "elasticsearch7": "npm:@elastic/elasticsearch@7",
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment