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

Escape html in ActivitiesPanel and Notificiations views #11706

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
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
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