Skip to content
Merged
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
21 changes: 12 additions & 9 deletions ui/src/widgets/ui-text/UIText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export default {
},
computed: {
...mapState('data', ['messages', 'properties']),
value () {
value: function () {
return this.textValue
},
label () {
// Sanetize the html to avoid XSS attacks
// Sanitize the html to avoid XSS attacks
return DOMPurify.sanitize(this.getProperty('label'))
},
layout () {
Expand Down Expand Up @@ -74,11 +74,7 @@ export default {
// make sure our v-model is updated to reflect the value from Node-RED
if (Object.prototype.hasOwnProperty.call(msg, 'payload')) {
// Sanitize the HTML to avoid XSS attacks
if (typeof msg.payload === 'string') {
this.textValue = DOMPurify.sanitize(msg.payload)
} else {
this.textValue = msg.payload
}
this.textValue = this.purify(msg.payload)
}
},
onLoad (msg) {
Expand All @@ -89,10 +85,17 @@ export default {
msg
})
if (Object.prototype.hasOwnProperty.call(msg, 'payload')) {
// Sanitize the HTML to avoid XSS attacks
this.textValue = DOMPurify.sanitize(msg.payload)
// Sanitize the HTML to avoid XSS attacks
this.textValue = this.purify(msg.payload)
}
}
},
purify (payload) {
if (typeof payload === 'string') {
return DOMPurify.sanitize(payload, { ADD_ATTR: ['target'] })
} else {
return payload
}
}
}
}
Expand Down
Loading