Commit 8a6a5502 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

make_URI: fix assertion failures (fix #3956)

Handles "\\hostname" properly.
On Windows, error out on "X:directory" instead of aborting. Looking up
the current directory of the specified drive letter would be a better,
though.
(cherry picked from commit 615bcffe5297b99422ffec435228ac015ae12d64)

Conflicts:

	src/text/strings.c
parent 51c3b786
......@@ -122,6 +122,7 @@ int main (void)
test_path ("/home/john/music.ogg", "file:///home/john/music.ogg");
test_path ("\\\\server/pub/music.ogg", "smb://server/pub/music.ogg");
test_path ("\\\\server\\pub\\music.ogg", "smb://server/pub/music.ogg");
test_path ("\\\\server", "smb://server");
/*int fd = open (".", O_RDONLY);
assert (fd != -1);*/
......
......@@ -1061,11 +1061,15 @@ char *make_URI (const char *path)
char *buf;
#ifdef WIN32
/* Drive letter */
if (isalpha (path[0]) && (path[1] == ':'))
{
if (asprintf (&buf, "file:///%c:", path[0]) == -1)
buf = NULL;
path += 2;
# warning Drive letter-relative path not implemented!
if (path[0] != DIR_SEP_CHAR)
return NULL;
}
else
#endif
......@@ -1098,6 +1102,9 @@ char *make_URI (const char *path)
snprintf (buf, sizeof (SMB_SCHEME) + 3 + hostlen,
SMB_SCHEME"://%s", path + 2);
path += 2 + hostlen;
if (path[0] == '\0')
return buf; /* Hostname without path */
}
else
if (path[0] != DIR_SEP_CHAR)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment