summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2010-09-12 11:42:37 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2010-09-12 11:42:37 +0000
commit4972283771211d2216485cb056b7485406a8d66c (patch)
treeab41a6db3291f571d2ad94a9f4722cb1b7450f3c
parent883c738c0a30622dcc4189b63bf1af18b45295fb (diff)
downloadnetsurf-4972283771211d2216485cb056b7485406a8d66c.tar.gz
netsurf-4972283771211d2216485cb056b7485406a8d66c.tar.bz2
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
-rw-r--r--content/fetchers/fetch_file.c21
1 files changed, 12 insertions, 9 deletions
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),