From 82fbdda588a502f7c2828ea532a319b0706465b9 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 3 Nov 2026 11:53:33 +0000 Subject: [PATCH] fix(platform): use the platform's path separators --- crates/platform/src/staging.rs | 2 +- crates/platform/src/staging/tests.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/platform/src/staging.rs b/crates/platform/src/staging.rs index 3f0806c592..eda1d8e65c 100644 --- a/crates/platform/src/staging.rs +++ b/crates/platform/src/staging.rs @@ -44,7 +44,7 @@ fn create_staging_as( keep: Option<&std::fs::Metadata>, ) -> std::io::Result<(PathBuf, std::fs::File)> { // One name, in `dir`: a separator in it would put the staging file somewhere else. - if name.is_empty() || name.contains(['/', '\\']) { + if name.is_empty() || name.chars().any(std::path::is_separator) { return Err(std::io::Error::new(std::io::ErrorKind::InvalidInput, "the file name is not a single name")); } // At most 128 bytes of the target's name, cut between characters, so the staging name fits diff --git a/crates/platform/src/staging/tests.rs b/crates/platform/src/staging/tests.rs index 1f1883dec2..a8738e6b7b 100644 --- a/crates/platform/src/staging/tests.rs +++ b/crates/platform/src/staging/tests.rs @@ -464,7 +464,8 @@ fn a_replaced_link_keeps_its_own_attributes_not_its_targets() { #[test] fn a_name_with_path_components_is_refused() { let dir = test_dir("components"); - for name in ["../out.pdf", "sub/out.pdf", "sub\\out.pdf", "/out.pdf", ""] { + let windows_only: &[&str] = if cfg!(windows) { &["sub\\out.pdf"] } else { &[] }; + for &name in ["../out.pdf", "sub/out.pdf", "/out.pdf", ""].iter().chain(windows_only) { let err = create_staging(&dir, name, StagingName::SuffixThenTag, [0xab]).unwrap_err(); assert_eq!(err.kind(), std::io::ErrorKind::InvalidInput, "{name:?}"); }