Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for interactive plantuml #2754

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
changes to optionally allow object tag
  • Loading branch information
bharatrajagopalan committed Dec 29, 2020
commit 571d1ddf0e2ead23ee1cb7691555fa7e1a81bd13
14 changes: 8 additions & 6 deletions server/modules/rendering/html-security/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ module.exports = {
//Changes to keep interactive plantuml object tag
bharatrajagopalan marked this conversation as resolved.
Show resolved Hide resolved

//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
Expand Down
16 changes: 10 additions & 6 deletions server/modules/rendering/markdown-plantuml/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <object ...>@startuml...@enduml</object>
token = state.push ('text', '', 0)
token.content = contents

//close object tag - </object>
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. <p style='display:none'>@startuml...@enduml</p>
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)
Expand Down