File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ pub mod component {
20
20
DotGitDir ,
21
21
#[ error( "The .gitmodules file must not be a symlink" ) ]
22
22
SymlinkedGitModules ,
23
+ #[ error( "Relative components '.' and '..' are disallowed" ) ]
24
+ Relative ,
23
25
}
24
26
25
27
/// Further specify what to check for in [`component()`](super::component())
@@ -78,6 +80,9 @@ pub fn component(
78
80
if input. is_empty ( ) {
79
81
return Err ( component:: Error :: Empty ) ;
80
82
}
83
+ if input == ".." || input == "." {
84
+ return Err ( component:: Error :: Relative ) ;
85
+ }
81
86
if protect_windows {
82
87
if input. find_byteset ( br"/\" ) . is_some ( ) {
83
88
return Err ( component:: Error :: PathSeparator ) ;
Original file line number Diff line number Diff line change @@ -253,6 +253,10 @@ mod component {
253
253
mktest ! ( con_with_extension, b"CON.abc" , Error :: WindowsReservedName ) ;
254
254
mktest ! ( con_with_middle, b"CON.tar.xz" , Error :: WindowsReservedName ) ;
255
255
mktest ! ( con_mixed_with_middle, b"coN.tar.xz " , Error :: WindowsReservedName ) ;
256
+ mktest ! ( dot_dot, b".." , Error :: Relative ) ;
257
+ mktest ! ( dot_dot_no_opts, b".." , Error :: Relative , NO_OPTS ) ;
258
+ mktest ! ( single_dot, b"." , Error :: Relative ) ;
259
+ mktest ! ( single_dot_no_opts, b"." , Error :: Relative , NO_OPTS ) ;
256
260
mktest ! (
257
261
conout_mixed_with_extension,
258
262
b"ConOut$ .xyz" ,
You can’t perform that action at this time.
0 commit comments