Commit f5ef10d
committed
Test Windows
When `<reserved>` is a reserved device name on Windows like `NUL`,
in addition to filenames where it is followed by an extension being
treated specially in the same way (`<reserved>.extension`),
filenames where the operation of repeatedly removing extensions
would produce `<reserved>` (`<reserved>.middle.extension`,
`<reserved>.middle1.middle2.extension`, and so forth) are also
treated by Windows like the reserved name.
The existing code in `gix-validate`, and thus the validation of
paths and refs that checks for reserved Windows device names,
already does the right thing here. While the existing tests are
presented as being for extensions, the implementation treats a name
as reserved when it is parsed as a reserved name followed by a `.`
(among other cases), regardless of whether what comes after the `.`
is actually an extension in the strict sense.
Therefore this is just adding regression tests to express the rule
more clearly and, more importantly, to protect against accidental
breakage in future changes. (Because of the way gitoxide uses this
validation, suhc breakage would likely introduce a vulnerability
similar to CVE-2024-35197, because this is part of how we safeguard
against malicious names when cloning untrusted remote repos.)
The idea to test this is inspired by a new check in `dunce`:
https://gitlab.com/kornelski/dunce/-/commit/0ceb0ae141bf78c6d9d68488a55d22cd94658339<reserved>.middle.extension filenames1 parent 6daaba3 commit f5ef10d
1 file changed
+7
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| |||
248 | 251 | | |
249 | 252 | | |
250 | 253 | | |
| 254 | + | |
| 255 | + | |
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
| |||
0 commit comments