From 448b0275ae4d62b31f64e3c6399d4fb5a045315c Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 16 Apr 2010 23:56:53 +0000 Subject: Fix file: handling on risc os, gtk, windows and framebuffer frontends svn path=/trunk/netsurf/; revision=10419 --- gtk/gtk_gui.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'gtk') diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c index 9d0c04bbb..8f5ccf3f9 100644 --- a/gtk/gtk_gui.c +++ b/gtk/gtk_gui.c @@ -757,18 +757,29 @@ utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len, char *path_to_url(const char *path) { - char *r = malloc(strlen(path) + FILE_SCHEME_PREFIX_LEN + 1); + int urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1; + char *url = malloc(urllen); - strcpy(r, FILE_SCHEME_PREFIX); - strcat(r, path); + if (*path == '/') { + path++; /* file: paths are already absolute */ + } - return r; + snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, path); + + return url; } char *url_to_path(const char *url) { - return strdup(url + FILE_SCHEME_PREFIX_LEN); + char *url_path = curl_unescape(url, 0); + char *path; + + /* return the absolute path including leading / */ + path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN - 1)); + curl_free(url_path); + + return path; } -- cgit v1.2.3