Skip to content

Commit b950e06

Browse files
authored
fix: stop dompurify from breaking draw.io diagrams (#7888)
Newer versions of dompurify strip <foreignobject> tags if not explicitly allowed. See cure53/DOMPurify#1040 Fixes #7744
1 parent 028dcd5 commit b950e06

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

client/components/editor/editor-asciidoc.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ export default {
228228
})
229229
230230
this.previewHTML = DOMPurify.sanitize($.html(), {
231-
ADD_TAGS: ['foreignObject']
231+
ADD_TAGS: ['foreignObject'],
232+
HTML_INTEGRATION_POINTS: { foreignobject: true }
232233
})
233234
},
234235
/**

client/components/editor/editor-markdown.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ export default {
454454
// this.$store.set('editor/content', newContent)
455455
this.processMarkers(this.cm.firstLine(), this.cm.lastLine())
456456
this.previewHTML = DOMPurify.sanitize(md.render(newContent), {
457-
ADD_TAGS: ['foreignObject']
457+
ADD_TAGS: ['foreignObject'],
458+
HTML_INTEGRATION_POINTS: { foreignobject: true }
458459
})
459460
this.$nextTick(() => {
460461
tabsetHelper.format()

server/modules/rendering/html-security/renderer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ module.exports = {
3434

3535
input = DOMPurify.sanitize(input, {
3636
ADD_ATTR: allowedAttrs,
37-
ADD_TAGS: allowedTags
37+
ADD_TAGS: allowedTags,
38+
HTML_INTEGRATION_POINTS: { foreignobject: true }
3839
})
3940
}
4041
return input

0 commit comments

Comments
 (0)