Skip to content

Commit

Permalink
Escape html in ActivitiesPanel and Notificiation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAndBear committed Oct 2, 2024
1 parent 4d2cd6c commit 207b8a0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Escape HTML characters in activities and notification view

We've fixed a bug where HTML characters were not escaped in the activities and notification view.
This could lead to potential XSS attacks.

https://github.com/owncloud/web/pull/11706
https://github.com/owncloud/web/issues/11705
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { useTask } from 'vue-concurrency'
import { call, Resource } from '@ownclouders/web-client'
import { DateTime } from 'luxon'
import { Activity } from '@ownclouders/web-client/graph/generated'
import escape from 'lodash-es/escape'
const visibilityObserver = new VisibilityObserver()
export default defineComponent({
Expand Down Expand Up @@ -82,7 +83,9 @@ export default defineComponent({
const getHtmlFromActivity = (activity: Activity) => {
let message = activity.template.message
for (const [key, value] of Object.entries(activity.template.variables)) {
message = message.replace(`{${key}}`, `<strong>${value.displayName || value.name}</strong>`)
const escapedValue = escape(value.displayName || value.name)
message = message.replace(`{${key}}`, `<strong>${escapedValue}</strong>`)
}
return message
}
Expand Down
3 changes: 2 additions & 1 deletion packages/web-runtime/src/components/Topbar/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<script lang="ts">
import { computed, onMounted, onUnmounted, ref, unref } from 'vue'
import isEmpty from 'lodash-es/isEmpty'
import escape from 'lodash-es/escape'
import {
useCapabilityStore,
useSpacesStore,
Expand Down Expand Up @@ -138,7 +139,7 @@ export default {
}
interpolatedMessage = interpolatedMessage.replace(
`{${param.name}}`,
`<strong>${label}</strong>`
`<strong>${escape(label)}</strong>`
)
}
}
Expand Down

0 comments on commit 207b8a0

Please sign in to comment.