Skip to content

Commit 1e7d09d

Browse files
authored
Merge pull request #1844 from EliahKagan/nonconsecutive-dots
Test Windows `<reserved>.middle.extension` filenames
2 parents ad7a94e + eaa59a3 commit 1e7d09d

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

gix-validate/tests/path/mod.rs

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#[test]
22
fn component_is_windows_device() {
3-
for device in ["con", "CONIN$", "lpt1.txt", "AUX", "Prn", "NUL", "COM9"] {
3+
for device in ["con", "CONIN$", "lpt1.txt", "AUX", "Prn", "NUL", "COM9", "nul.a.b "] {
44
assert!(gix_validate::path::component_is_windows_device(device.into()));
55
}
6-
for not_device in ["coni", "CONIN", "lpt", "AUXi", "aPrn", "NULl", "COM"] {
6+
for not_device in ["coni", "CONIN", "lpt", "AUXi", "aPrn", "NULl", "COM", "a.nul.b "] {
77
assert!(!gix_validate::path::component_is_windows_device(not_device.into()));
88
}
99
}
@@ -53,10 +53,10 @@ mod component {
5353

5454
mktest!(ascii, b"ascii-only_and-that");
5555
mktest!(unicode, "😁👍👌".as_bytes());
56-
mktest!(backslashes_on_unix, b"\\", UNIX_OPTS);
56+
mktest!(backslashes_on_unix, br"\", UNIX_OPTS);
5757
mktest!(drive_letters_on_unix, b"c:", UNIX_OPTS);
5858
mktest!(virtual_drive_letters_on_unix, "֍:".as_bytes(), UNIX_OPTS);
59-
mktest!(unc_path_on_unix, b"\\\\?\\pictures", UNIX_OPTS);
59+
mktest!(unc_path_on_unix, br"\\?\pictures", UNIX_OPTS);
6060
mktest!(not_dot_git_longer, b".gitu", NO_OPTS);
6161
mktest!(not_dot_git_longer_all, b".gitu");
6262
mktest!(not_dot_gitmodules_shorter, b".gitmodule", Symlink, NO_OPTS);
@@ -66,7 +66,7 @@ mod component {
6666
mktest!(dot_gitmodules_as_file, b".gitmodules", UNIX_OPTS);
6767
mktest!(
6868
starts_with_dot_git_with_backslashes_on_linux,
69-
b".git\\hooks\\pre-commit",
69+
br".git\hooks\pre-commit",
7070
UNIX_OPTS
7171
);
7272
mktest!(not_dot_git_shorter, b".gi", NO_OPTS);
@@ -82,6 +82,9 @@ mod component {
8282
mktest!(conin_without_dollar, b"conin");
8383
mktest!(not_con, b"com");
8484
mktest!(also_not_con, b"co");
85+
mktest!(con_as_middle, b"x.CON.zip");
86+
mktest!(con_after_space, b" CON");
87+
mktest!(con_after_space_mixed, b" coN.tar.xz");
8588
mktest!(not_nul, b"null");
8689
mktest!(
8790
not_dot_gitmodules_shorter_hfs,
@@ -136,7 +139,7 @@ mod component {
136139
mktest!(dot_git_upper, b".GIT", Error::DotGitDir, NO_OPTS);
137140
mktest!(
138141
starts_with_dot_git_with_backslashes_on_windows,
139-
b".git\\hooks\\pre-commit",
142+
br".git\hooks\pre-commit",
140143
Error::PathSeparator
141144
);
142145
mktest!(dot_git_upper_hfs, ".GIT\u{200e}".as_bytes(), Error::DotGitDir);
@@ -225,10 +228,10 @@ mod component {
225228
mktest!(path_separator_slash_trailing, b"a/", Error::PathSeparator);
226229
mktest!(path_separator_slash_only, b"/", Error::PathSeparator);
227230
mktest!(slashes_on_windows, b"/", Error::PathSeparator, ALL_OPTS);
228-
mktest!(backslashes_on_windows, b"\\", Error::PathSeparator, ALL_OPTS);
229-
mktest!(path_separator_backslash_between, b"a\\b", Error::PathSeparator);
230-
mktest!(path_separator_backslash_leading, b"\\a", Error::PathSeparator);
231-
mktest!(path_separator_backslash_trailing, b"a\\", Error::PathSeparator);
231+
mktest!(backslashes_on_windows, br"\", Error::PathSeparator, ALL_OPTS);
232+
mktest!(path_separator_backslash_between, br"a\b", Error::PathSeparator);
233+
mktest!(path_separator_backslash_leading, br"\a", Error::PathSeparator);
234+
mktest!(path_separator_backslash_trailing, br"a\", Error::PathSeparator);
232235
mktest!(aux_mixed, b"Aux", Error::WindowsReservedName);
233236
mktest!(aux_with_extension, b"aux.c", Error::WindowsReservedName);
234237
mktest!(com_lower, b"com1", Error::WindowsReservedName);
@@ -248,6 +251,8 @@ mod component {
248251
mktest!(prn_mixed_with_extension, b"PrN.abc", Error::WindowsReservedName);
249252
mktest!(con, b"CON", Error::WindowsReservedName);
250253
mktest!(con_with_extension, b"CON.abc", Error::WindowsReservedName);
254+
mktest!(con_with_middle, b"CON.tar.xz", Error::WindowsReservedName);
255+
mktest!(con_mixed_with_middle, b"coN.tar.xz ", Error::WindowsReservedName);
251256
mktest!(
252257
conout_mixed_with_extension,
253258
b"ConOut$ .xyz",
@@ -261,7 +266,10 @@ mod component {
261266
Error::WindowsPathPrefix,
262267
ALL_OPTS
263268
);
264-
mktest!(unc_path, b"\\\\?\\pictures", Error::PathSeparator, ALL_OPTS);
269+
mktest!(unc_net_path, br"\\host", Error::PathSeparator, ALL_OPTS);
270+
mktest!(unc_path, br"\\?\pictures", Error::PathSeparator, ALL_OPTS);
271+
mktest!(unc_device_path, br"\\.\pictures", Error::PathSeparator, ALL_OPTS);
272+
mktest!(unc_nt_obj_path, br"\??\pictures", Error::PathSeparator, ALL_OPTS);
265273

266274
#[test]
267275
fn ntfs_gitmodules() {

0 commit comments

Comments
 (0)