summaryrefslogtreecommitdiff
path: root/gtk/gtk_gui.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2010-04-16 23:56:53 +0000
committerVincent Sanders <vince@netsurf-browser.org>2010-04-16 23:56:53 +0000
commit448b0275ae4d62b31f64e3c6399d4fb5a045315c (patch)
treed42cf1938d8ef3497381b7a8858651044f58ea7c /gtk/gtk_gui.c
parent01eb197f56ae69b0e4dba5d3475585d9cdda599c (diff)
downloadnetsurf-448b0275ae4d62b31f64e3c6399d4fb5a045315c.tar.gz
netsurf-448b0275ae4d62b31f64e3c6399d4fb5a045315c.tar.bz2
Fix file: handling on risc os, gtk, windows and framebuffer frontends
svn path=/trunk/netsurf/; revision=10419
Diffstat (limited to 'gtk/gtk_gui.c')
-rw-r--r--gtk/gtk_gui.c21
1 files changed, 16 insertions, 5 deletions
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;
}