Skip to content

Commit 4791e31

Browse files
committed
further testing of .git path variants
This is to see if anything should be done to more effectively prevent paths containing `.git` (icase). In conclusion, I think it's fine to keep allowing it as none of the component-validations really kicks in on Linux if backslashes are used as path separator. Thus, `.git` shouldn't be more special than `..` for example. The only way to fix this on Linux would be to either enable Windows protections, or to disallow `\` as path seprator by default which seems too limitting. Windows Users will naturally be protected as path-splitting will turn these into components, with each of them checked as normal.
1 parent f3edaa3 commit 4791e31

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

gix-validate/tests/path/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ mod component {
5454
mktest!(not_dot_gitmodules_longer, b".gitmodulesa", Symlink, NO_OPTS);
5555
mktest!(not_dot_gitmodules_longer_all, b".gitmodulesa", Symlink, ALL_OPTS);
5656
mktest!(dot_gitmodules_as_file, b".gitmodules", UNIX_OPTS);
57+
mktest!(
58+
starts_with_dot_git_with_backslashes_on_linux,
59+
b".git\\hooks\\precommit",
60+
UNIX_OPTS
61+
);
5762
mktest!(not_dot_git_shorter, b".gi", NO_OPTS);
5863
mktest!(not_dot_git_shorter_ntfs_8_3, b"gi~1");
5964
mktest!(not_dot_git_longer_ntfs_8_3, b"gitu~1");
@@ -119,6 +124,11 @@ mod component {
119124
mktest!(dot_git_lower_hfs, ".g\u{200c}it".as_bytes(), Error::DotGitDir);
120125
mktest!(dot_git_mixed_hfs_simple, b".Git", Error::DotGitDir);
121126
mktest!(dot_git_upper, b".GIT", Error::DotGitDir, NO_OPTS);
127+
mktest!(
128+
starts_with_dot_git_with_backslashes_on_windows,
129+
b".git\\hooks\\precommit",
130+
Error::PathSeparator
131+
);
122132
mktest!(dot_git_upper_hfs, ".GIT\u{200e}".as_bytes(), Error::DotGitDir);
123133
mktest!(dot_git_upper_ntfs_8_3, b"GIT~1", Error::DotGitDir);
124134
mktest!(dot_git_mixed, b".gIt", Error::DotGitDir, NO_OPTS);

0 commit comments

Comments
 (0)