Skip to content

Commit

Permalink
Merge pull request #1394 from bartbutenaers/sanetize-html
Browse files Browse the repository at this point in the history
Sanitize HTML Injections
  • Loading branch information
joepavitt authored Oct 15, 2024
2 parents 465f328 + 72188bc commit 26816b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ui/src/widgets/ui-button/UIButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
</template>

<script>
import DOMPurify from 'dompurify'
import { mapState } from 'vuex' // eslint-disable-line import/order
export default {
Expand Down Expand Up @@ -47,7 +49,8 @@ export default {
return icon && this.iconPosition === 'right' ? mdiIcon : undefined
},
label () {
return this.getProperty('label')
// Sanetize the html to avoid XSS attacks
return DOMPurify.sanitize(this.getProperty('label'))
},
iconPosition () {
return this.getProperty('iconPosition')
Expand Down
5 changes: 4 additions & 1 deletion ui/src/widgets/ui-notification/UINotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
</template>

<script>
import DOMPurify from 'dompurify'
import { mapState } from 'vuex'
export default {
Expand All @@ -60,7 +61,9 @@ export default {
...mapState('data', ['messages']),
value: function () {
// Get the value (i.e. the notification text content) from the last input msg
return this.messages[this.id]?.payload
const value = this.messages[this.id]?.payload
// Sanetize the html to avoid XSS attacks
return DOMPurify.sanitize(value)
},
allowConfirm () {
return this.getProperty('allowConfirm')
Expand Down
3 changes: 2 additions & 1 deletion ui/src/widgets/ui-text/UIText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default {
value: function () {
const m = this.messages[this.id] || {}
if (Object.prototype.hasOwnProperty.call(m, 'payload')) {
return m.payload
// Sanetize the html to avoid XSS attacks
return DOMPurify.sanitize(m.payload)
}
return ''
},
Expand Down

0 comments on commit 26816b6

Please sign in to comment.