summaryrefslogtreecommitdiff
path: root/beos
diff options
context:
space:
mode:
authorFrançois Revel <mmu_man@netsurf-browser.org>2010-08-12 13:33:53 +0000
committerFrançois Revel <mmu_man@netsurf-browser.org>2010-08-12 13:33:53 +0000
commit4cb2657d191d626e3ddb37166fa591ce877d0434 (patch)
treef6037dc8aba680c63c3a7d65b91d6479d7bdcaa1 /beos
parent00aeb20334eabb680bcfc1512f4bf58fdf5147a5 (diff)
downloadnetsurf-4cb2657d191d626e3ddb37166fa591ce877d0434.tar.gz
netsurf-4cb2657d191d626e3ddb37166fa591ce877d0434.tar.bz2
Copy over the gtk implementation of url_to_path/path_to_url(). This fixes getting the mime type of local files.
svn path=/trunk/netsurf/; revision=10688
Diffstat (limited to 'beos')
-rw-r--r--beos/beos_gui.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/beos/beos_gui.cpp b/beos/beos_gui.cpp
index 768ae7680..d8cb4bbb2 100644
--- a/beos/beos_gui.cpp
+++ b/beos/beos_gui.cpp
@@ -1165,17 +1165,32 @@ utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len,
char *path_to_url(const char *path)
{
- char *r = (char *)malloc(strlen(path) + FILE_SCHEME_PREFIX_LEN + 1);
+ int urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
+ char *url = (char *)malloc(urllen);
- strcpy(r, FILE_SCHEME_PREFIX);
- strcat(r, path);
+ if (url == NULL) {
+ return NULL;
+ }
+
+ 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;
}
bool cookies_update(const char *domain, const struct cookie_data *data)