smb: Fixed URL encoded URLs not working

This commit is contained in:
Steve Holme 2014-12-06 20:46:54 +00:00
parent 58b317c9da
commit 864f17d894

View File

@ -42,6 +42,7 @@
#include "vtls/vtls.h" #include "vtls/vtls.h"
#include "curl_ntlm_core.h" #include "curl_ntlm_core.h"
#include "curl_memory.h" #include "curl_memory.h"
#include "escape.h"
/* The last #include file should be: */ /* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
@ -175,6 +176,7 @@ struct smb_request {
static CURLcode smb_setup(struct connectdata *conn) static CURLcode smb_setup(struct connectdata *conn)
{ {
CURLcode result = CURLE_OK;
struct smb_request *req; struct smb_request *req;
char *slash; char *slash;
char *path; char *path;
@ -187,18 +189,29 @@ static CURLcode smb_setup(struct connectdata *conn)
req->state = SMB_REQUESTING; req->state = SMB_REQUESTING;
req->result = CURLE_OK; req->result = CURLE_OK;
/* URL decode the path */
result = Curl_urldecode(conn->data, conn->data->state.path, 0, &path, NULL,
TRUE);
if(result)
return result;
/* Parse the share and path */ /* Parse the share and path */
path = conn->data->state.path;
req->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path); req->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
if(!req->share) if(!req->share) {
Curl_safefree(path);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
}
slash = strchr(req->share, '/'); slash = strchr(req->share, '/');
if(!slash) if(!slash)
slash = strchr(req->share, '\\'); slash = strchr(req->share, '\\');
if(!slash) if(!slash) {
Curl_safefree(path);
return CURLE_URL_MALFORMAT; return CURLE_URL_MALFORMAT;
}
*slash++ = 0; *slash++ = 0;
req->path = slash; req->path = slash;
@ -207,6 +220,8 @@ static CURLcode smb_setup(struct connectdata *conn)
*slash = '\\'; *slash = '\\';
} }
Curl_safefree(path);
return CURLE_OK; return CURLE_OK;
} }