Skip to content

Commit 6267c25

Browse files
committed
Fix NSURL path on Windows for network paths like \\xxx
1 parent f0e33a4 commit 6267c25

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2023-07-26 Frederik Seiffert <frederik@algoriddim.com>
2+
3+
* Source/NSURL.m:
4+
Fix NSURL path on Windows for network paths like \\xxx.
5+
16
2023-07-25 Frederik Seiffert <frederik@algoriddim.com>
27

38
* Headers/Foundation/NSFileManager.h:

Source/NSURL.m

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,24 +1497,24 @@ - (char*) _path: (char*)buf withEscapes: (BOOL)withEscapes
14971497
}
14981498

14991499
#if defined(_WIN32)
1500-
/* On windows a file URL path may be of the form C:\xxx (ie we should
1501-
* not insert the leading slash).
1500+
/* On Windows a file URL path may be of the form C:\xxx or \\xxx,
1501+
* and in both cases we should not insert the leading slash.
15021502
* Also the vertical bar symbol may have been used instead of the
15031503
* colon, so we need to convert that.
15041504
*/
15051505
if (myData->isFile == YES)
15061506
{
1507-
if (ptr[1] && isalpha(ptr[1]))
1508-
{
1509-
if (ptr[2] == ':' || ptr[2] == '|')
1510-
{
1511-
if (ptr[3] == '\0' || ptr[3] == '/' || ptr[3] == '\\')
1512-
{
1513-
ptr[2] = ':';
1514-
ptr++;
1515-
}
1516-
}
1517-
}
1507+
if ((ptr[1] && isalpha(ptr[1]))
1508+
&& (ptr[2] == ':' || ptr[2] == '|')
1509+
&& (ptr[3] == '\0' || ptr[3] == '/' || ptr[3] == '\\'))
1510+
{
1511+
ptr[2] = ':';
1512+
ptr++; // remove leading slash
1513+
}
1514+
else if (ptr[1] == '\\' && ptr[2] == '\\')
1515+
{
1516+
ptr++; // remove leading slash
1517+
}
15181518
}
15191519
#endif
15201520
return ptr;

0 commit comments

Comments
 (0)