Don't corrupt UNC paths when normalizing with wxPATH_NORM_LONG
After the fixes to UNC paths handling, Normalize(wxPATH_NORM_LONG) started adding an extra colon after the UNC paths. Fix this by using wxGetVolumeString() instead of constructing this thing manually and add a unit test checking for this. Closes #22275.
This commit is contained in:
parent
e50c7b2e2f
commit
35d08e6a87
2 changed files with 9 additions and 2 deletions
|
|
@ -2240,8 +2240,7 @@ wxString wxFileName::GetLongPath() const
|
|||
HANDLE hFind;
|
||||
|
||||
if ( HasVolume() )
|
||||
pathOut = GetVolume() +
|
||||
GetVolumeSeparator(wxPATH_DOS) +
|
||||
pathOut = wxGetVolumeString(GetVolume(), wxPATH_DOS) +
|
||||
GetPathSeparator(wxPATH_DOS);
|
||||
else
|
||||
pathOut.clear();
|
||||
|
|
|
|||
|
|
@ -561,6 +561,14 @@ TEST_CASE("wxFileName::UNC", "[filename]")
|
|||
CHECK( fn.GetVolume() == "\\\\share2" );
|
||||
CHECK( GetDOSPath(fn) == "\\path2" );
|
||||
|
||||
fn.SetPath("\\\\server\\volume\\path", wxPATH_DOS);
|
||||
fn.AppendDir("subdir");
|
||||
CHECK( fn.GetFullPath(wxPATH_DOS) == "\\\\server\\volume\\path\\subdir\\name.ext" );
|
||||
|
||||
// Check for a bug with normalization breaking the path (#22275).
|
||||
fn.Normalize(wxPATH_NORM_LONG);
|
||||
CHECK( fn.GetFullPath(wxPATH_DOS) == "\\\\server\\volume\\path\\subdir\\name.ext" );
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
// Check that doubled backslashes in the beginning of the path are not
|
||||
// misinterpreted as UNC volume when we have a drive letter in the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue