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
added null checks and cleanup
  • Loading branch information
bharatrajagopalan committed Dec 29, 2020
commit 8a1fd73f3b1f17a8e9cd919f1f4ae85c785080d4
17 changes: 12 additions & 5 deletions server/modules/rendering/html-security/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ 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
if (`${pumlImageFormat}` == 'svg') {
if (typeof pumlImageFormat !== 'undefined' &&
pumlImageFormat &&
pumlImageFormat == 'svg') {
allowedTags.push('object')
allowedAttrs.push('data')
allowedAttrs.push('type')
Expand All @@ -51,7 +53,12 @@ module.exports = {
// insert the plantuml inside the object as text for search
let isPumlNode=false

if (data.tagName === 'object') {
if (data.tagName === 'object' &&
typeof pumlServer !== 'undefined' && pumlServer &&
typeof pumlObjectStyle !== 'undefined' && pumlObjectStyle &&
typeof pumlObjectType !== 'undefined' && pumlObjectType &&
typeof pumlObjectClass !== 'undefined' && pumlObjectClass
) {
//console.log ("Found object node - validating")
//remove node if it doesn't conform to plantuml structure
if (!( 'data' in node.attributes
Expand All @@ -72,9 +79,9 @@ module.exports = {
) {
//console.log ("Plantuml node found - setting atribute values")
isPumlNode=true
node.setAttribute ('type', `${pumlObjectType}`)
node.setAttribute ('style', `${pumlObjectStyle}`)
node.setAttribute ('class', `${pumlObjectClass}`)
node.setAttribute ('type', pumlObjectType)
node.setAttribute ('style', pumlObjectStyle)
node.setAttribute ('class', pumlObjectClass)
node.setAttribute ('alt', '')
}

Expand Down
10 changes: 5 additions & 5 deletions server/modules/rendering/markdown-plantuml/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module.exports = {
// alt is constructed from children. No point in populating it here.
token.attrs = [ [ 'src' , `${server}/${imageFormat}/${zippedCode}` ],
[ 'alt' , '' ],
['class', `${pumlObjectClass}` ]
['class', pumlObjectClass ]
]
token.block = true
token.children = altToken
Expand All @@ -145,9 +145,9 @@ module.exports = {
token = state.push('uml_diagram_obj', 'object', 0)
token.attrs = [ [ 'data' , `${server}/${imageFormat}/${zippedCode}`],
[ 'alt' , '' ],
[ 'class', `${pumlObjectClass}` ],
[ 'style', `${pumlObjectStyle}` ],
[ 'type', `${pumlObjectType}` ]
[ 'class', pumlObjectClass ],
[ 'style', pumlObjectStyle ],
[ 'type', pumlObjectType ]
]
token.block = true
token.children = altToken
Expand All @@ -164,7 +164,7 @@ module.exports = {
// alt is constructed from children. No point in populating it here.
token.attrs = [ [ 'src' , `${server}/${imageFormat}/${zippedCode}` ],
[ 'alt' , '' ],
['class', `${pumlObjectClass}`]
['class', pumlObjectClass]
]
token.block = true
token.children = altToken
Expand Down