From 8bdc0738f9da149f565b4d3e9fe63bd4f23cc170 Mon Sep 17 00:00:00 2001 From: localhost Date: Sat, 30 Sep 2023 17:32:32 +0200 Subject: [PATCH] dompurify ytdlp messages --- utils/ytdlp.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils/ytdlp.js b/utils/ytdlp.js index 656079c..7c1b16e 100644 --- a/utils/ytdlp.js +++ b/utils/ytdlp.js @@ -1,4 +1,5 @@ const child_process = require('child_process') +const DOMPurify = require('isomorphic-dompurify') async function downloadVideo(url, ws) { return new Promise((resolve, reject) => { @@ -8,7 +9,14 @@ async function downloadVideo(url, ws) { const msg = data.toString().trim() if (!msg) return - if (ws) ws.send(`DATA - ${msg}`) + if (ws) ws.send(`DATA - ${DOMPurify.sanitize(msg)}`) + }) + + child.stderr.on("data", data => { + const msg = data.toString().trim() + if (!msg) return + + if (ws) ws.send(`DATA - ${DOMPurify.sanitize(msg)}`) }) child.on("close", async (code, signal) => {