From 0da7cf10d6d4d4dffac5a55339e40a43df5fd82f Mon Sep 17 00:00:00 2001 From: Kunall Banerjee Date: Wed, 4 Mar 2026 19:42:17 -0500 Subject: [PATCH] Sanitize canonicalized `--user-data-dir` --- crates/paths/src/paths.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/paths/src/paths.rs b/crates/paths/src/paths.rs index 40e10fb3badaf2e00c6dbcc75af06e7b758faa81..212a68d8ef48f034c78825955be07bef17fb2748 100644 --- a/crates/paths/src/paths.rs +++ b/crates/paths/src/paths.rs @@ -4,6 +4,7 @@ use std::env; use std::path::{Path, PathBuf}; use std::sync::{LazyLock, OnceLock}; +use util::paths::SanitizedPath; pub use util::paths::home_dir; use util::rel_path::RelPath; @@ -71,8 +72,10 @@ pub fn set_custom_data_dir(dir: &str) -> &'static PathBuf { CUSTOM_DATA_DIR.get_or_init(|| { let path = PathBuf::from(dir); std::fs::create_dir_all(&path).expect("failed to create custom data directory"); - path.canonicalize() - .expect("failed to canonicalize custom data directory's path to an absolute path") + let canonicalized = path + .canonicalize() + .expect("failed to canonicalize custom data directory's path to an absolute path"); + SanitizedPath::new(&canonicalized).as_path().to_path_buf() }) }