diff --git a/ChangeLog b/ChangeLog index 49cc0035f..cc4d9b23c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-07-26 Frederik Seiffert + + * Source/NSURL.m: + Fix NSURL path on Windows for network paths like \\xxx. + 2023-07-25 Frederik Seiffert * Headers/Foundation/NSFileManager.h: diff --git a/Source/NSURL.m b/Source/NSURL.m index 82fba6412..229ae22f9 100644 --- a/Source/NSURL.m +++ b/Source/NSURL.m @@ -1497,24 +1497,24 @@ - (char*) _path: (char*)buf withEscapes: (BOOL)withEscapes } #if defined(_WIN32) - /* On windows a file URL path may be of the form C:\xxx (ie we should - * not insert the leading slash). + /* On Windows a file URL path may be of the form C:\xxx or \\xxx, + * and in both cases we should not insert the leading slash. * Also the vertical bar symbol may have been used instead of the * colon, so we need to convert that. */ if (myData->isFile == YES) { - if (ptr[1] && isalpha(ptr[1])) - { - if (ptr[2] == ':' || ptr[2] == '|') - { - if (ptr[3] == '\0' || ptr[3] == '/' || ptr[3] == '\\') - { - ptr[2] = ':'; - ptr++; - } - } - } + if ((ptr[1] && isalpha(ptr[1])) + && (ptr[2] == ':' || ptr[2] == '|') + && (ptr[3] == '\0' || ptr[3] == '/' || ptr[3] == '\\')) + { + ptr[2] = ':'; + ptr++; // remove leading slash + } + else if (ptr[1] == '\\' && ptr[2] == '\\') + { + ptr++; // remove leading slash + } } #endif return ptr;