mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-31 07:39:17 +00:00
Data merge: an extended-length drive path is a local file, not a refusal
Review caught a wrong assertion in my own test. `\\?\C:\x` is the extended-length spelling of `C:\x`: craft-docpath parses it as Root::VerbatimDrive, is_absolute, and its own suite classifies it PathKind::Local. The test asserted it was refused, so it would have failed on Windows -- the one platform it runs on. A data file can already name C:\secret\x.png, so refusing the long spelling would have shut out long paths without shutting anything out. It is now asserted the other way, and the refusal list keeps a device path in its place. Each shape was checked against the pinned craft-docpath through resolve(), which recognises Windows forms on every platform, so the verdicts are first-hand and not read off the source: Network for the extended UNC prefix, Device for \\.\pipe, GLOBALROOT, CON and NUL.png, and Ok for \\?\C:\secret\x.png.
This commit is contained in:
1 parent
93ab34f515
commit
ff35b3561f
1 file changed
+15
-3
@@ -545,16 +545,28 @@ mod image_path_tests {
|
||||
}
|
||||
|
||||
/// The Windows shapes `craft-docpath` refuses, asserted where they have meaning: the extended
|
||||
/// UNC prefix, a device namespace path, and a legacy device name.
|
||||
/// UNC prefix, a device namespace path, and a legacy device name (with an extension, since a
|
||||
/// reserved name is reserved whatever follows it).
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn windows_device_and_extended_paths_are_refused() {
|
||||
fn windows_device_and_network_paths_are_refused() {
|
||||
let (data, doc) = (Path::new(r"C:\work\data"), Path::new(r"C:\work\doc"));
|
||||
for cell in [r"\\?\UNC\192.0.2.1\share\x.png", r"\\.\pipe\x", r"\\?\C:\secret\x.png", "CON", "NUL.png"] {
|
||||
for cell in [r"\\?\UNC\192.0.2.1\share\x.png", r"\\.\pipe\x", r"\\?\GLOBALROOT\Device\HarddiskVolume1\x", "CON", "NUL.png"] {
|
||||
assert!(image_candidates(cell, Some(data), Some(doc)).is_empty(), "{cell}");
|
||||
}
|
||||
}
|
||||
|
||||
/// An extended-length path is not one of them: `\\?\C:\x` names a local file, the same one
|
||||
/// `C:\x` names, and `craft-docpath`'s own suite classifies it `PathKind::Local`. A data file
|
||||
/// could already give the plain spelling, so refusing this one would shut out long paths
|
||||
/// without shutting anything out (noted in review).
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn an_extended_length_drive_path_is_a_local_file() {
|
||||
let (data, doc) = (Path::new(r"C:\work\data"), Path::new(r"C:\work\doc"));
|
||||
assert!(!image_candidates(r"\\?\C:\secret\x.png", Some(data), Some(doc)).is_empty());
|
||||
}
|
||||
|
||||
/// Resolution beside the data and the document, with absolute paths this platform means.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user