From d090adc1f12c5fdf5d076d6c0e244f00648f77f1 Mon Sep 17 00:00:00 2001
From: wvffle
Date: Fri, 1 Jul 2022 13:55:13 +0000
Subject: [PATCH] Sanitize html
---
front/package.json | 2 ++
front/src/components/AboutPod.vue | 16 ++++++---------
front/src/components/Home.vue | 4 ++--
front/src/components/SanitizedHtml.vue | 20 +++++++++++++++++++
front/src/components/auth/Plugin.vue | 20 +++++++++----------
front/src/components/common/ContentForm.vue | 4 ++--
.../components/common/RenderedDescription.vue | 2 +-
front/src/components/library/TrackBase.vue | 4 ++--
.../manage/moderation/InstancePolicyCard.vue | 2 +-
.../manage/moderation/NotesThread.vue | 2 +-
.../manage/moderation/ReportCard.vue | 2 +-
.../notifications/NotificationRow.vue | 9 +++++----
front/src/init/globalComponents.ts | 2 ++
front/src/views/Notifications.vue | 2 +-
front/src/views/admin/ChannelDetail.vue | 5 ++++-
front/src/views/admin/library/AlbumDetail.vue | 5 ++++-
.../src/views/admin/library/ArtistDetail.vue | 5 ++++-
front/src/views/admin/library/TrackDetail.vue | 5 ++++-
front/yarn.lock | 14 ++++++++++++-
yarn.lock | 4 ++++
20 files changed, 89 insertions(+), 40 deletions(-)
create mode 100644 front/src/components/SanitizedHtml.vue
create mode 100644 yarn.lock
diff --git a/front/package.json b/front/package.json
index d000e7b3e..d504ea0e0 100644
--- a/front/package.json
+++ b/front/package.json
@@ -23,6 +23,7 @@
"axios": "0.27.2",
"axios-auth-refresh": "3.3.1",
"diff": "5.1.0",
+ "dompurify": "^2.3.8",
"focus-trap": "6.9.4",
"fomantic-ui-css": "2.8.8",
"howler": "2.2.3",
@@ -50,6 +51,7 @@
"vuex-router-sync": "5.0.0"
},
"devDependencies": {
+ "@types/dompurify": "^2.3.3",
"@types/jest": "28.1.3",
"@types/jquery": "3.5.14",
"@types/lodash-es": "4.17.6",
diff --git a/front/src/components/AboutPod.vue b/front/src/components/AboutPod.vue
index 4c3d0dfdd..30f9c5b19 100644
--- a/front/src/components/AboutPod.vue
+++ b/front/src/components/AboutPod.vue
@@ -1,6 +1,3 @@
-
-
@@ -98,9 +95,9 @@ We render some markdown to html here, the content is set by the admin so we shou
Rules
-
@@ -116,9 +113,9 @@ We render some markdown to html here, the content is set by the admin so we shou
Terms and privacy policy
-
@@ -444,7 +441,6 @@ export default {
},
data () {
return {
- // TODO (wvffle): Remove v-html
markdown: new showdown.Converter(),
showAllowedDomains: false
}
diff --git a/front/src/components/Home.vue b/front/src/components/Home.vue
index fddf12f47..f766cb068 100644
--- a/front/src/components/Home.vue
+++ b/front/src/components/Home.vue
@@ -45,10 +45,10 @@
-
+import { sanitize } from 'dompurify'
+import { computed, h } from 'vue'
+
+interface Props {
+ tag?: string
+ html: string
+}
+
+const props = withDefaults(defineProps
(), {
+ tag: 'div'
+})
+
+const html = computed(() => sanitize(props.html))
+const root = () => h(props.tag, { innerHTML: html.value })
+
+
+
+
+
\ No newline at end of file
diff --git a/front/src/components/auth/Plugin.vue b/front/src/components/auth/Plugin.vue
index 1e9f1339a..12d5f49a6 100644
--- a/front/src/components/auth/Plugin.vue
+++ b/front/src/components/auth/Plugin.vue
@@ -4,9 +4,9 @@
@submit.prevent="submit"
>
{{ plugin.label }}
-
@@ -84,9 +84,9 @@
v-model="values[field.name]"
type="text"
>
-
-
diff --git a/front/src/components/common/ContentForm.vue b/front/src/components/common/ContentForm.vue
index 5cf0f44b7..f9fc3f673 100644
--- a/front/src/components/common/ContentForm.vue
+++ b/front/src/components/common/ContentForm.vue
@@ -36,9 +36,9 @@
Nothing to preview.
-
diff --git a/front/src/components/common/RenderedDescription.vue b/front/src/components/common/RenderedDescription.vue
index aab47ca58..9fa2551a9 100644
--- a/front/src/components/common/RenderedDescription.vue
+++ b/front/src/components/common/RenderedDescription.vue
@@ -1,7 +1,7 @@
diff --git a/front/src/components/manage/moderation/InstancePolicyCard.vue b/front/src/components/manage/moderation/InstancePolicyCard.vue
index 3267e42a0..646c622dd 100644
--- a/front/src/components/manage/moderation/InstancePolicyCard.vue
+++ b/front/src/components/manage/moderation/InstancePolicyCard.vue
@@ -67,7 +67,7 @@