File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ pub mod component {
2020 DotGitDir ,
2121 #[ error( "The .gitmodules file must not be a symlink" ) ]
2222 SymlinkedGitModules ,
23+ #[ error( "Relative components '.' and '..' are disallowed" ) ]
24+ Relative ,
2325 }
2426
2527 /// Further specify what to check for in [`component()`](super::component())
@@ -78,6 +80,9 @@ pub fn component(
7880 if input. is_empty ( ) {
7981 return Err ( component:: Error :: Empty ) ;
8082 }
83+ if input == ".." || input == "." {
84+ return Err ( component:: Error :: Relative ) ;
85+ }
8186 if protect_windows {
8287 if input. find_byteset ( br"/\" ) . is_some ( ) {
8388 return Err ( component:: Error :: PathSeparator ) ;
Original file line number Diff line number Diff line change @@ -253,6 +253,10 @@ mod component {
253253 mktest ! ( con_with_extension, b"CON.abc" , Error :: WindowsReservedName ) ;
254254 mktest ! ( con_with_middle, b"CON.tar.xz" , Error :: WindowsReservedName ) ;
255255 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 ) ;
256260 mktest ! (
257261 conout_mixed_with_extension,
258262 b"ConOut$ .xyz" ,
You can’t perform that action at this time.
0 commit comments