summaryrefslogtreecommitdiff
path: root/framebuffer
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 /framebuffer
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 'framebuffer')
-rw-r--r--framebuffer/findfile.c27
-rw-r--r--framebuffer/misc.c5
2 files changed, 23 insertions, 9 deletions
diff --git a/framebuffer/findfile.c b/framebuffer/findfile.c
index 64d96fcb4..a00f0f835 100644
--- a/framebuffer/findfile.c
+++ b/framebuffer/findfile.c
@@ -23,6 +23,8 @@
#include <stdlib.h>
#include <string.h>
+#include <curl/curl.h>
+
#include "utils/log.h"
#include "utils/url.h"
@@ -30,12 +32,29 @@
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);
+
+ if (*path == '/') {
+ path++; /* file: paths are already absolute */
+ }
+
+ snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, path);
+
+ return url;
+}
+
+
+char *url_to_path(const char *url)
+{
+ char *url_path = curl_unescape(url, 0);
+ char *path;
- strcpy(r, FILE_SCHEME_PREFIX);
- strcat(r, path);
+ /* return the absolute path including leading / */
+ path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN - 1));
+ curl_free(url_path);
- return r;
+ return path;
}
/**
diff --git a/framebuffer/misc.c b/framebuffer/misc.c
index c5f367019..5e351f517 100644
--- a/framebuffer/misc.c
+++ b/framebuffer/misc.c
@@ -40,10 +40,6 @@ bool cookies_update(const char *domain, const struct cookie_data *data)
return true;
}
-char *url_to_path(const char *url)
-{
- return strdup(url + 5);
-}
/**
* Return the filename part of a full path
@@ -51,7 +47,6 @@ char *url_to_path(const char *url)
* \param path full path and filename
* \return filename (will be freed with free())
*/
-
char *filename_from_path(char *path)
{
char *leafname;