diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-10-29 09:53:21 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-10-29 09:53:21 +0000 |
commit | e9c835ad06bdded6a720ad59054a7b058ace4d9c (patch) | |
tree | 8bca4c3cf5adfc5a0ec6367c7e7537b6115db82c /lib | |
parent | 0701b973dfdf13af115d5731fae16c0447c68d88 (diff) |
David Hull made the file: URL parser also accept the somewhat sloppy file
syntax: file:/path. I added test case 203 to verify this.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/url.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -2002,9 +2002,19 @@ static CURLcode CreateConnection(struct SessionHandle *data, * proxy -- and we don't know if we will need to use SSL until we parse the * url ... ************************************************************/ - if((2 == sscanf(data->change.url, "%64[^:]://%[^\n]", + if((2 == sscanf(data->change.url, "%64[^:]:%[^\n]", conn->protostr, conn->path)) && strequal(conn->protostr, "file")) { + if(conn->path[0] == '/' && conn->path[1] == '/') { + /* Allow omitted hostname (e.g. file:/<path>). This is not strictly + * speaking a valid file: URL by RFC 1738, but treating file:/<path> as + * file://localhost/<path> is similar to how other schemes treat missing + * hostnames. See RFC 1808. */ + + /* This cannot be done with strcpy() in a portable manner, since the + memory areas overlap! */ + memmove(conn->path, conn->path + 2, strlen(conn->path + 2)+1); + } /* * we deal with file://<host>/<path> differently since it supports no * hostname other than "localhost" and "127.0.0.1", which is unique among |