mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-10-20 22:41:22 +02:00
fix: windows path handling
This commit is contained in:
1 parent
037b50e345
commit
f02938bf14
4 files changed
+15
-4
No files matched your search
Generated
+1
@@ -1762,6 +1762,7 @@ dependencies = [
|
||||
"crossbeam-channel",
|
||||
"directories",
|
||||
"dirs 7.0.0",
|
||||
"dunce",
|
||||
"env_logger",
|
||||
"flate2",
|
||||
"futures-util",
|
||||
|
||||
@@ -119,6 +119,7 @@ serde_yaml = "0.9"
|
||||
thiserror = "2.0"
|
||||
regex-lite = "0.1"
|
||||
tempfile = "3"
|
||||
dunce = "1"
|
||||
maxminddb = "0.32"
|
||||
quick-xml = { version = "0.42", features = ["serialize"] }
|
||||
|
||||
|
||||
@@ -683,7 +683,9 @@ impl ExtensionManager {
|
||||
dir: &Path,
|
||||
manifest: &serde_json::Value,
|
||||
) -> Result<Extension, Box<dyn std::error::Error>> {
|
||||
let absolute = dir.canonicalize()?;
|
||||
// dunce, not std: on Windows std returns the `\\?\C:\...` form, which the
|
||||
// Extensions page would show and `--load-extension` would be handed.
|
||||
let absolute = dunce::canonicalize(dir)?;
|
||||
if !path_is_load_extension_safe(&absolute) {
|
||||
return Err(err_code("EXTENSION_PATH_HAS_COMMA"));
|
||||
}
|
||||
@@ -956,7 +958,7 @@ impl ExtensionManager {
|
||||
manifest: &serde_json::Value,
|
||||
explicit_name_provided: bool,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let absolute = dir.canonicalize()?;
|
||||
let absolute = dunce::canonicalize(dir)?;
|
||||
if !path_is_load_extension_safe(&absolute) {
|
||||
return Err(err_code("EXTENSION_PATH_HAS_COMMA"));
|
||||
}
|
||||
@@ -2201,7 +2203,11 @@ mod tests {
|
||||
|
||||
let mgr = ExtensionManager::new();
|
||||
let source = write_unpacked_fixture(&tmp.path().join("linked-extension"), "Linked Fixture");
|
||||
let canonical = source.canonicalize().unwrap().to_string_lossy().to_string();
|
||||
let canonical = dunce::canonicalize(&source)
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
assert!(!canonical.starts_with(r"\\?\"), "{canonical}");
|
||||
let ext = mgr
|
||||
.add_unpacked_extension("Ignored".to_string(), &source, true)
|
||||
.unwrap();
|
||||
|
||||
@@ -180,7 +180,10 @@ impl AgentEnv {
|
||||
pub fn from_process() -> Option<Self> {
|
||||
Some(Self {
|
||||
platform: Platform::current(),
|
||||
home: dirs::home_dir()?,
|
||||
// std, not `dirs`: on Windows `dirs` asks for the Profile known folder
|
||||
// and ignores USERPROFILE, while the clients themselves (Node's
|
||||
// os.homedir(), Rust's home_dir) follow USERPROFILE.
|
||||
home: std::env::home_dir()?,
|
||||
appdata: env_path("APPDATA"),
|
||||
xdg_config_home: env_path("XDG_CONFIG_HOME"),
|
||||
codex_home: env_path("CODEX_HOME"),
|
||||
|
||||
Reference in new issue
Block a user