From 98b690a900148f09299d678f2b8abb3dbff22640 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 17 Apr 2010 10:43:12 +0000 Subject: Fix file://localhost/ handling svn path=/trunk/netsurf/; revision=10422 --- amiga/misc.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/amiga/misc.c b/amiga/misc.c index be01ea73b..17ea4c22b 100755 --- a/amiga/misc.c +++ b/amiga/misc.c @@ -62,20 +62,23 @@ char *url_to_path(const char *url) char *tmps, *unesc; CURL *curl; - tmps = strstr(url, "///localhost/") + 13; + if (strncmp(url, "file://", SLEN("file://")) != 0) + return NULL; + + url += SLEN("file://"); - if(tmps < url) tmps = strstr(url,"///") + 3; + if (strncmp(url, "localhost", SLEN("localhost")) == 0) + url += SLEN("localhost"); - if(tmps >= url) + url += SLEN("/"); + + if(curl = curl_easy_init()) { - if(curl = curl_easy_init()) - { - unesc = curl_easy_unescape(curl,tmps,0,NULL); - tmps = strdup(unesc); - curl_free(unesc); - curl_easy_cleanup(curl); - return tmps; - } + unesc = curl_easy_unescape(curl,url,0,NULL); + tmps = strdup(unesc); + curl_free(unesc); + curl_easy_cleanup(curl); + return tmps; } return strdup((char *)url); @@ -83,9 +86,9 @@ char *url_to_path(const char *url) char *path_to_url(const char *path) { - char *r = malloc(strlen(path) + FILE_SCHEME_PREFIX_LEN + 1); + char *r = malloc(strlen(path) + SLEN("file:///") + 1); - strcpy(r, FILE_SCHEME_PREFIX); + strcpy(r, "file:///"); strcat(r, path); return r; -- cgit v1.2.3