diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 01:06:48 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 01:06:48 +0100 |
| commit | 1d4eba1ca43ad6ad6632c903eec79501c8c6183d (patch) | |
| tree | f667cab69cc08fc700272bd1a8c2c353b1b03776 | |
| parent | copyparty: never send the password to foreign hosts (diff) | |
| download | senator-sperma-1d4eba1ca43ad6ad6632c903eec79501c8c6183d.tar.gz senator-sperma-1d4eba1ca43ad6ad6632c903eec79501c8c6183d.zip | |
yt-dlp: ignore configs and stop option injection
| -rw-r--r-- | src/commands/utilities.rs | 8 | ||||
| -rw-r--r-- | src/voice/mod.rs | 11 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/commands/utilities.rs b/src/commands/utilities.rs index 33d732f..79f4508 100644 --- a/src/commands/utilities.rs +++ b/src/commands/utilities.rs | |||
| @@ -483,7 +483,11 @@ async fn run_download( | |||
| 483 | }; | 483 | }; |
| 484 | 484 | ||
| 485 | let mut cmd = tokio::process::Command::new("yt-dlp"); | 485 | let mut cmd = tokio::process::Command::new("yt-dlp"); |
| 486 | cmd.arg("-f") | 486 | // `--ignore-config` keeps a planted config file from injecting options; |
| 487 | // `--` stops a user-supplied URL from being parsed as a flag. | ||
| 488 | cmd.arg("--ignore-config") | ||
| 489 | .arg("--no-playlist") | ||
| 490 | .arg("-f") | ||
| 487 | .arg("bestaudio/bestvideo+bestaudio") | 491 | .arg("bestaudio/bestvideo+bestaudio") |
| 488 | .arg("--merge-output-format") | 492 | .arg("--merge-output-format") |
| 489 | .arg("mp4") | 493 | .arg("mp4") |
| @@ -492,7 +496,7 @@ async fn run_download( | |||
| 492 | if is_audio { | 496 | if is_audio { |
| 493 | cmd.arg("--extract-audio").arg("--audio-format").arg(fmt); | 497 | cmd.arg("--extract-audio").arg("--audio-format").arg(fmt); |
| 494 | } | 498 | } |
| 495 | cmd.arg(sanitize_yt_url(url)); | 499 | cmd.arg("--").arg(sanitize_yt_url(url)); |
| 496 | 500 | ||
| 497 | let output = cmd | 501 | let output = cmd |
| 498 | .output() | 502 | .output() |
diff --git a/src/voice/mod.rs b/src/voice/mod.rs index 5a89f93..0b6022c 100644 --- a/src/voice/mod.rs +++ b/src/voice/mod.rs | |||
| @@ -231,7 +231,16 @@ fn decode_stream(mss: MediaSourceStream) -> Result<songbird::input::Input> { | |||
| 231 | /// Works for both finite media and live streams (yt-dlp handles the difference). | 231 | /// Works for both finite media and live streams (yt-dlp handles the difference). |
| 232 | pub async fn ytdlp_download(url: &str) -> Result<Vec<u8>> { | 232 | pub async fn ytdlp_download(url: &str) -> Result<Vec<u8>> { |
| 233 | let output = tokio::process::Command::new("yt-dlp") | 233 | let output = tokio::process::Command::new("yt-dlp") |
| 234 | .args(["-f", "bestaudio", "-o", "-", "--no-playlist", url]) | 234 | .args([ |
| 235 | "--ignore-config", | ||
| 236 | "-f", | ||
| 237 | "bestaudio", | ||
| 238 | "-o", | ||
| 239 | "-", | ||
| 240 | "--no-playlist", | ||
| 241 | "--", | ||
| 242 | url, | ||
| 243 | ]) | ||
| 235 | .stdout(std::process::Stdio::piped()) | 244 | .stdout(std::process::Stdio::piped()) |
| 236 | .stderr(std::process::Stdio::piped()) | 245 | .stderr(std::process::Stdio::piped()) |
| 237 | .output() | 246 | .output() |
