File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,6 @@ pub mod path_splitting {
61
61
}
62
62
}
63
63
}
64
- if ret. is_empty ( ) {
65
- return Err ( PathSplitError :: ExtractionPathEscapesDirectory (
66
- entry_path,
67
- "path resolves to the top-level directory" ,
68
- ) ) ;
69
- }
70
64
71
65
Ok ( ( ret, is_dir) )
72
66
}
@@ -131,6 +125,13 @@ pub mod path_splitting {
131
125
/* Split entries by directory components, and normalize any non-literal paths
132
126
* (e.g. '..', '.', leading '/', repeated '/'). */
133
127
let ( all_components, is_dir) = normalize_parent_dirs ( entry_path) ?;
128
+
129
+ /* If the entry resolves to the top-level directory, we don't error, but instead just
130
+ * avoid writing any data to that directory entry. */
131
+ if all_components. is_empty ( ) {
132
+ continue ;
133
+ }
134
+
134
135
/* If the entry is a directory by mode, then it does not need to end in '/'. */
135
136
let is_dir = is_dir || data. is_dir_by_mode ( ) ;
136
137
/* Split basename and dirname. */
@@ -209,7 +210,7 @@ pub mod path_splitting {
209
210
( vec![ "a\\ b" ] , true )
210
211
) ;
211
212
assert ! ( normalize_parent_dirs( "a/../../b" ) . is_err( ) ) ;
212
- assert ! ( normalize_parent_dirs( "./" ) . is_err ( ) ) ;
213
+ assert_eq ! ( normalize_parent_dirs( "./" ) . unwrap ( ) , ( vec! [ ] , true ) ) ;
213
214
}
214
215
215
216
#[ test]
You can’t perform that action at this time.
0 commit comments