diff --git a/crates/engine/src/automation/file_access.rs b/crates/engine/src/automation/file_access.rs index 249d3483c..8d04488e6 100644 --- a/crates/engine/src/automation/file_access.rs +++ b/crates/engine/src/automation/file_access.rs @@ -345,6 +345,12 @@ fn device_name(n: &str) -> bool { && stem.chars().last().is_some_and(|c| c.is_ascii_digit() || matches!(c, '¹' | '²' | '³'))) } +/// Prefix Windows device-name components of a generated export path with `_`. +/// Apply after character filtering and suffix construction, so a safe suffix stays unchanged. +pub fn escape_device_names(path: &str) -> String { + path.split('/').map(|name| if device_name(name) { format!("_{name}") } else { name.to_string() }).collect::>().join("/") +} + thread_local! { static ROOTS: RefCell>> = const { RefCell::new(None) }; }