From 4972283771211d2216485cb056b7485406a8d66c Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 12 Sep 2010 11:42:37 +0000 Subject: Ensure the file that is read for info is in the platform's native path format, whilst the path used for any links is in the correct URL format. svn path=/trunk/netsurf/; revision=10761 --- content/fetchers/fetch_file.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'content/fetchers') diff --git a/content/fetchers/fetch_file.c b/content/fetchers/fetch_file.c index 8537d1805..126a161f4 100644 --- a/content/fetchers/fetch_file.c +++ b/content/fetchers/fetch_file.c @@ -369,6 +369,7 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx, char *title; /* pretty printed title */ url_func_result res; /* result from url routines */ char *up; /* url of parent */ + char *path; /* url for list entries */ bool compare; /* result of url compare */ DIR *scandir; /* handle for enumerating the directory */ @@ -433,12 +434,9 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx, if (ent->d_name[0] == '.') continue; - snprintf(urlpath, - sizeof urlpath, - "%s%s%s", - ctx->path, - (ctx->path[strlen(ctx->path) - 1] == '/')?"":"/" , - ent->d_name); + strncpy(urlpath, ctx->path, sizeof urlpath); + if (path_add_part(urlpath, sizeof urlpath, ent->d_name) == false) + continue; if (stat(urlpath, &ent_stat) != 0) { ent_stat.st_mode = 0; @@ -460,11 +458,14 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx, } } + if((path = path_to_url(urlpath)) == NULL) + continue; + if (S_ISREG(ent_stat.st_mode)) { /* regular file */ dirlist_generate_row(even, false, - urlpath, + path, ent->d_name, fetch_filetype(urlpath), ent_stat.st_size, @@ -474,7 +475,7 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx, /* directory */ dirlist_generate_row(even, true, - urlpath, + path, ent->d_name, messages_get("FileDirectory"), -1, @@ -484,7 +485,7 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx, /* something else */ dirlist_generate_row(even, false, - urlpath, + path, ent->d_name, "", -1, @@ -492,6 +493,8 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx, buffer, sizeof(buffer)); } + free(path); + if (fetch_file_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer), -- cgit v1.2.3