summaryrefslogtreecommitdiff
path: root/framebuffer
diff options
context:
space:
mode:
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;