2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -1208,6 +1208,9 @@ impl PathBuf {
1208
1208
/// * if `path` has a root but no prefix (e.g., `\windows`), it
1209
1209
/// replaces everything except for the prefix (if any) of `self`.
1210
1210
/// * if `path` has a prefix but no root, it replaces `self`.
1211
+ /// * if `self` has a verbatim prefix (e.g. `\\?\C:\windows`)
1212
+ /// and `path` is not empty, the new path is normalized: all references
1213
+ /// to `.` and `..` are removed.
1211
1214
///
1212
1215
/// # Examples
1213
1216
///
@@ -1254,7 +1257,7 @@ impl PathBuf {
1254
1257
self . as_mut_vec ( ) . truncate ( 0 ) ;
1255
1258
1256
1259
// verbatim paths need . and .. removed
1257
- } else if comps. prefix_verbatim ( ) {
1260
+ } else if comps. prefix_verbatim ( ) && !path . inner . is_empty ( ) {
1258
1261
let mut buf: Vec < _ > = comps. collect ( ) ;
1259
1262
for c in path. components ( ) {
1260
1263
match c {
Original file line number Diff line number Diff line change @@ -1271,6 +1271,7 @@ pub fn test_push() {
1271
1271
tp ! ( r"\\?\A:\x\y" , "/foo" , r"\\?\A:\foo" ) ;
1272
1272
tp ! ( r"\\?\A:" , r"..\foo\." , r"\\?\A:\foo" ) ;
1273
1273
tp ! ( r"\\?\A:\x\y" , r".\foo\." , r"\\?\A:\x\y\foo" ) ;
1274
+ tp ! ( r"\\?\A:\x\y" , r"" , r"\\?\A:\x\y\" ) ;
1274
1275
}
1275
1276
}
1276
1277
0 commit comments