fix(platform): a staging name is refused for a path separator only

This commit is contained in:
Dylan M. Taylor committed 2026-11-03 11:53:21 +00:00
1 parent af7381301d
commit e239721816
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -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
+1 -1
View File
@@ -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:?}");
}