File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -1208,6 +1208,9 @@ impl PathBuf {
12081208 /// * if `path` has a root but no prefix (e.g., `\windows`), it
12091209 /// replaces everything except for the prefix (if any) of `self`.
12101210 /// * 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.
12111214 ///
12121215 /// # Examples
12131216 ///
@@ -1254,7 +1257,7 @@ impl PathBuf {
12541257 self . as_mut_vec ( ) . truncate ( 0 ) ;
12551258
12561259 // verbatim paths need . and .. removed
1257- } else if comps. prefix_verbatim ( ) {
1260+ } else if comps. prefix_verbatim ( ) && !path . inner . is_empty ( ) {
12581261 let mut buf: Vec < _ > = comps. collect ( ) ;
12591262 for c in path. components ( ) {
12601263 match c {
Original file line number Diff line number Diff line change @@ -1271,6 +1271,7 @@ pub fn test_push() {
12711271 tp ! ( r"\\?\A:\x\y" , "/foo" , r"\\?\A:\foo" ) ;
12721272 tp ! ( r"\\?\A:" , r"..\foo\." , r"\\?\A:\foo" ) ;
12731273 tp ! ( r"\\?\A:\x\y" , r".\foo\." , r"\\?\A:\x\y\foo" ) ;
1274+ tp ! ( r"\\?\A:\x\y" , r"" , r"\\?\A:\x\y\" ) ;
12741275 }
12751276}
12761277
You can’t perform that action at this time.
0 commit comments