diff --git a/server/modules/rendering/html-security/renderer.js b/server/modules/rendering/html-security/renderer.js index 9d53433a..956ae6c5 100644 --- a/server/modules/rendering/html-security/renderer.js +++ b/server/modules/rendering/html-security/renderer.js @@ -35,12 +35,14 @@ module.exports = { //Changes to keep interactive plantuml object tag //only allow specific attributes for plantuml object node - allowedTags.push('object') - allowedAttrs.push('data') - allowedAttrs.push('type') - allowedAttrs.push('style') - allowedAttrs.push('class') - allowedAttrs.push('alt') + if (`${pumlImageFormat}` == 'svg') { + allowedTags.push('object') + allowedAttrs.push('data') + allowedAttrs.push('type') + allowedAttrs.push('style') + allowedAttrs.push('class') + allowedAttrs.push('alt') + } DOMPurify.addHook('uponSanitizeElement', (node, data) => { // keep object node only if it is diff --git a/server/modules/rendering/markdown-plantuml/renderer.js b/server/modules/rendering/markdown-plantuml/renderer.js index 59135382..8c12961f 100644 --- a/server/modules/rendering/markdown-plantuml/renderer.js +++ b/server/modules/rendering/markdown-plantuml/renderer.js @@ -172,15 +172,19 @@ module.exports = { token.map = [ startLine, nextLine ] token.markup = markup - //add puml source in object node for wikijs search index - //as wikijs will not index svg content from object tag - //i.e. like - token = state.push ('text', '', 0) - token.content = contents - //close object tag - token = state.push('uml_diagram_close', 'object', -1) } + + //Create hidden text inside html for wikijs search index + // text won't be visible or occupy any space but will be searchable + //i.e.
+ token = state.push ('hidden', 'p', 0) + token.attrs = [ [ 'style', 'display:none'] ] + token = state.push ('text', '', 0) + token.content = contents + token = state.push('hidden_close', 'p', -1) + //Interactive plantuml changes end here state.line = nextLine + (autoClosed ? 1 : 0)