Skip to content

Commit

Permalink
escaped-html-notifcation
Browse files Browse the repository at this point in the history
Signed-off-by: Vikalp Rusia <vikalprusia@gmail.com>
  • Loading branch information
VikalpRusia committed Sep 25, 2024
1 parent 0efb3bd commit 27034f3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/rancher-desktop/components/Snapshots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface Data {
interface Methods {
pollingStart: () => void,
currentTime: () => string,
escapeSnapshotName: (name: string|undefined) => string,
}
interface Computed {
Expand Down Expand Up @@ -85,6 +86,18 @@ export default Vue.extend<Data, Methods, Computed, never>({
return date.format('YYYY-MM-DD HH:mm');
},
escapeSnapshotName(value: string|undefined) {
if (!value) {
return '';
}
return value
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
},
},
});
</script>
Expand All @@ -102,7 +115,7 @@ export default Vue.extend<Data, Methods, Computed, never>({
@close="snapshotEvent=null"
>
<span
v-clean-html="t(`snapshots.info.${ snapshotEvent.type }.${ snapshotEvent.result }`, { snapshot: snapshotEvent.snapshotName, error: snapshotEvent.error }, true)"
v-clean-html="t(`snapshots.info.${ snapshotEvent.type }.${ snapshotEvent.result }`, { snapshot: escapeSnapshotName(snapshotEvent.snapshotName), error: snapshotEvent.error }, true)"
class="event-message"
/>
<span
Expand Down

0 comments on commit 27034f3

Please sign in to comment.