From e2397218162cb58166b493432f63c35e1be8ce78 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 3 Nov 2026 11:53:21 +0000 Subject: [PATCH] fix(platform): a staging name is refused for a path separator only --- crates/platform/src/staging.rs | 2 +- crates/platform/src/staging/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/platform/src/staging.rs b/crates/platform/src/staging.rs index c00f5834ad..3f0806c592 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(['/', '\\']) || std::path::Path::new(name).components().count() != 1 { + if name.is_empty() || name.contains(['/', '\\']) { 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 e638d6bbb4..1f1883dec2 100644 --- a/crates/platform/src/staging/tests.rs +++ b/crates/platform/src/staging/tests.rs @@ -464,7 +464,7 @@ 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", "", "."] { + for name in ["../out.pdf", "sub/out.pdf", "sub\\out.pdf", "/out.pdf", ""] { let err = create_staging(&dir, name, StagingName::SuffixThenTag, [0xab]).unwrap_err(); assert_eq!(err.kind(), std::io::ErrorKind::InvalidInput, "{name:?}"); }