Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ export const getDefaultSampleNote = () => {
> ` + t('notes', 'Nextcloud, a safe home for all your data') + `
`
}

export const escapeHtml = (str) => {
const element = document.createElement('div')
element.textContent = str
return element.innerHTML
}
6 changes: 5 additions & 1 deletion src/components/EditorMarkdownIt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import MarkdownIt from 'markdown-it'
import { generateUrl } from '@nextcloud/router'
import { escapeHtml } from '../Util.js'
export default {
name: 'EditorMarkdownIt',
Expand Down Expand Up @@ -145,7 +146,10 @@ export default {
if (download) {
const dlimgpath = generateUrl('svg/core/actions/download?color=ffffff')
return '<div class="download-file"><a href="' + path.replace(/"/g, '&quot;') + '"><div class="download-icon"><img class="download-icon-inner" src="' + dlimgpath + '">' + token.content + '</div></a></div>'
const tokenContent = escapeHtml(token.content)
return '<div class="download-file"><a href="' + path.replace(/"/g, '&quot;') + '"><div class="download-icon"><img class="download-icon-inner" '
+ 'src="' + dlimgpath + '">'
+ tokenContent + '</div></a></div>'
} else {
// pass token to default renderer.
return defaultRender(tokens, idx, options, env, self)
Expand Down
Loading