Encode URLs to allow for spaces in directory names

This commit is contained in:
cold-brewed 2019-02-20 00:09:24 -05:00
parent 59febcdb9c
commit ece17f6a61
2 changed files with 17 additions and 6 deletions

View File

@ -3299,6 +3299,7 @@ static int generic_action_ok_network(const char *path,
enum msg_hash_enums enum_idx)
{
char url_path[PATH_MAX_LENGTH];
char url_path_encoded[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
unsigned type_id2 = 0;
file_transfer_t *transf = NULL;
@ -3308,6 +3309,7 @@ static int generic_action_ok_network(const char *path,
bool suppress_msg = false;
url_path[0] = '\0';
url_path_encoded[0] = '\0';
switch (enum_idx)
{
@ -3376,7 +3378,8 @@ static int generic_action_ok_network(const char *path,
transf = (file_transfer_t*)calloc(1, sizeof(*transf));
strlcpy(transf->path, url_path, sizeof(transf->path));
task_push_http_transfer(url_path, suppress_msg, url_label, callback, transf);
net_http_urlencode_full(url_path_encoded, url_path, sizeof(url_path_encoded));
task_push_http_transfer(url_path_encoded, suppress_msg, url_label, callback, transf);
return generic_action_ok_displaylist_push(path, NULL,
label, type, idx, entry_idx, type_id2);
@ -3676,7 +3679,11 @@ static int action_ok_download_generic(const char *path,
transf->enum_idx = enum_idx;
strlcpy(transf->path, path, sizeof(transf->path));
net_http_urlencode_full(s3, s2, sizeof(s));
if (string_is_equal_fast(path, s, sizeof(path))) {
net_http_urlencode_full(s3, s, sizeof(s3));
} else {
net_http_urlencode_full(s3, s2, sizeof(s3));
}
task_push_http_transfer(s3, suppress_msg, msg_hash_to_str(enum_idx), cb, transf);
#endif

View File

@ -268,9 +268,11 @@ finish:
if (!err && !strstr(state->path, file_path_str(FILE_PATH_INDEX_DIRS_URL)))
{
char *parent_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *parent_dir_encoded = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
file_transfer_t *transf = NULL;
parent_dir[0] = '\0';
parent_dir_encoded[0] = '\0';
fill_pathname_parent_dir(parent_dir,
state->path, PATH_MAX_LENGTH * sizeof(char));
@ -283,10 +285,12 @@ finish:
transf->enum_idx = MSG_UNKNOWN;
strlcpy(transf->path, parent_dir, sizeof(transf->path));
task_push_http_transfer(parent_dir, true,
net_http_urlencode_full(parent_dir_encoded, parent_dir, PATH_MAX_LENGTH * sizeof(char));
task_push_http_transfer(parent_dir_encoded, true,
"index_dirs", cb_net_generic_subdir, transf);
free(parent_dir);
free(parent_dir_encoded);
}
if (state)