@@ -169,10 +169,12 @@ export default {
if (!this.video.error) {
document.title = this.video.title + " - Piped";
- this.video.description = this.video.description
- .replaceAll("http://www.youtube.com", "")
- .replaceAll("https://www.youtube.com", "")
- .replaceAll("\n", "
");
+ this.video.description = this.purifyHTML(
+ this.video.description
+ .replaceAll("http://www.youtube.com", "")
+ .replaceAll("https://www.youtube.com", "")
+ .replaceAll("\n", "
"),
+ );
this.$refs.videoPlayer.loadVideo();
}
diff --git a/src/main.js b/src/main.js
index e45cdaed..fd873392 100644
--- a/src/main.js
+++ b/src/main.js
@@ -11,6 +11,8 @@ import("uikit/dist/js/uikit-core.min");
import router from "@/router/router";
import App from "./App.vue";
+import DOMPurify from 'dompurify';
+
import("./registerServiceWorker");
const mixin = {
@@ -58,6 +60,9 @@ const mixin = {
return response.json();
});
},
+ purifyHTML(original) {
+ return DOMPurify.sanitize(original);
+ }
},
};
diff --git a/yarn.lock b/yarn.lock
index 0bb6390a..2abc53a6 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3373,6 +3373,11 @@ domhandler@^2.3.0:
dependencies:
domelementtype "1"
+dompurify@^2.2.9:
+ version "2.2.9"
+ resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.2.9.tgz#4b42e244238032d9286a0d2c87b51313581d9624"
+ integrity sha512-+9MqacuigMIZ+1+EwoEltogyWGFTJZWU3258Rupxs+2CGs4H914G9er6pZbsme/bvb5L67o2rade9n21e4RW/w==
+
domutils@^1.5.1, domutils@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a"