diff --git a/src-tauri/src/core/utils/download.rs b/src-tauri/src/core/utils/download.rs index 47b2d485d..ae34df25c 100644 --- a/src-tauri/src/core/utils/download.rs +++ b/src-tauri/src/core/utils/download.rs @@ -4,6 +4,8 @@ use crate::core::utils::normalize_path; use futures_util::StreamExt; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use std::collections::HashMap; +use std::path::Component; +use std::path::Prefix; use std::time::Duration; use tauri::{Emitter, State}; use tokio::fs::File; @@ -165,6 +167,24 @@ async fn _download_files_internal( let save_path = normalize_path(&save_path); // enforce scope + // Remove \\?\ prefix on Windows for correct path comparison + #[cfg(windows)] + let save_path = { + let mut comps = save_path.components(); + if let Some(Component::Prefix(prefix_comp)) = comps.next() { + if let Prefix::Verbatim(_) = prefix_comp.kind() { + // Skip the \\?\ prefix + comps.as_path().to_path_buf() + } else { + save_path.clone() + } + } else { + save_path.clone() + } + }; + #[cfg(not(windows))] + let save_path = save_path.clone(); + if !save_path.starts_with(&jan_data_folder) { return Err(format!( "Path {} is outside of Jan data folder {}",