From e7829bf21346b6921a4474df1613b9124ed06b33 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 5 Aug 2024 09:30:26 +0200 Subject: [PATCH] Encode file names in playlist --- crates/librqbit/src/http_api.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/librqbit/src/http_api.rs b/crates/librqbit/src/http_api.rs index 9ef08ffc..7d1e5786 100644 --- a/crates/librqbit/src/http_api.rs +++ b/crates/librqbit/src/http_api.rs @@ -1,6 +1,6 @@ use anyhow::Context; use axum::body::Bytes; -use axum::extract::{Path, Query, Request, State}; +use axum::extract::{Path, Query, State}; use axum::response::{IntoResponse, Redirect}; use axum::routing::{get, post}; use futures::future::BoxFuture; @@ -148,8 +148,7 @@ impl HttpApi { .into_iter() .enumerate() .filter_map(|(file_idx, f)| { - let file_name = f.name; - let is_playable = mime_guess::from_path(&file_name) + let is_playable = mime_guess::from_path(&f.name) .first() .map(|mime| { mime.type_() == mime_guess::mime::VIDEO @@ -157,6 +156,7 @@ impl HttpApi { }) .unwrap_or(false); if is_playable { + let file_name = urlencoding::encode(&f.name); Some(format!( "http://{host}/torrents/{idx}/stream/{file_idx}/{file_name}" ))