dompurify ytdlp messages

This commit is contained in:
localhost 2023-09-30 17:32:32 +02:00
parent 967b1fc3ac
commit 8bdc0738f9
1 changed files with 9 additions and 1 deletions

View File

@ -1,4 +1,5 @@
const child_process = require('child_process') const child_process = require('child_process')
const DOMPurify = require('isomorphic-dompurify')
async function downloadVideo(url, ws) { async function downloadVideo(url, ws) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -8,7 +9,14 @@ async function downloadVideo(url, ws) {
const msg = data.toString().trim() const msg = data.toString().trim()
if (!msg) return 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) => { child.on("close", async (code, signal) => {