diff --git a/src/common/filename.cpp b/src/common/filename.cpp index d31d3a5f35..1a40f08a10 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -290,7 +290,7 @@ inline bool IsDOSPathSep(wxUniChar ch) // like a UNC path static bool IsUNCPath(const wxString& path, wxPathFormat format) { - return format == wxPATH_DOS && + return wxFileName::GetFormat(format) == wxPATH_DOS && path.length() >= 4 && // "\\a" can't be a UNC path IsDOSPathSep(path[0u]) && IsDOSPathSep(path[1u]) && diff --git a/tests/filename/filenametest.cpp b/tests/filename/filenametest.cpp index 3134bbe53d..ba8a326a77 100644 --- a/tests/filename/filenametest.cpp +++ b/tests/filename/filenametest.cpp @@ -550,6 +550,14 @@ TEST_CASE("wxFileName::UNC", "[filename]") fn.Assign("\\\\share2\\path2\\name.ext", wxPATH_DOS); CHECK( fn.GetVolume() == "share2" ); CHECK( fn.GetPath(wxPATH_NO_SEPARATOR, wxPATH_DOS) == "\\path2" ); + +#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 + // beginning. + fn.Assign("d:\\\\root\\directory\\file"); + CHECK( fn.GetFullPath() == "d:\\root\\directory\\file" ); +#endif // __WINDOWS__ } TEST_CASE("wxFileName::VolumeUniqueName", "[filename]")