From 0d39c69763f7918fdd884516140e23b4eab51b10 Mon Sep 17 00:00:00 2001 From: John Tytgat Date: Wed, 2 Apr 2008 00:43:51 +0000 Subject: - riscos/gui.c(path_to_url): escape the characters which need to be escaped when converting the host path to file: URL. - utils/{url.c,url.h}(url_escape): * added parameter 'toskip' to specify number of input characters which need to be skipped in the escape process. This avoids extra malloc buffer juggling. * added parameter 'escexceptions' to specify the characters which need to be excluded from the escape process. Solves SF tracker ID 1910169. Note that when discname in path contains '/' characters (case: "file:///Sunfish#192.168.0.50::/home/joty.$/jo.html") or there is no discname specified at all (case "file:///HostFS:$/jo.htm"), you need an UnixLib fix as in http://www.riscos.info/websvn/listing.php?repname=gccsdk&path=%2Ftrunk%2Fgcc4%2F&rev=3395&sc=1 svn path=/trunk/netsurf/; revision=4069 --- riscos/gui.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'riscos') diff --git a/riscos/gui.c b/riscos/gui.c index dfb0520f3..f7173fe81 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -1965,16 +1965,16 @@ void ro_msg_window_info(wimp_message *message) char *path_to_url(const char *path) { int spare; - char *buffer = 0; - char *url = 0; + char *buffer, *url, *escurl; os_error *error; + url_func_result url_err; error = xosfscontrol_canonicalise_path(path, 0, 0, 0, 0, &spare); if (error) { LOG(("xosfscontrol_canonicalise_path failed: 0x%x: %s", error->errnum, error->errmess)); warn_user("PathToURL", error->errmess); - return 0; + return NULL; } buffer = malloc(1 - spare); @@ -1984,7 +1984,7 @@ char *path_to_url(const char *path) warn_user("NoMemory", 0); free(buffer); free(url); - return 0; + return NULL; } error = xosfscontrol_canonicalise_path(path, buffer, 0, 0, 1 - spare, @@ -1995,14 +1995,30 @@ char *path_to_url(const char *path) warn_user("PathToURL", error->errmess); free(buffer); free(url); - return 0; + return NULL; } - strcpy(url, "file://"); - __unixify(buffer, __RISCOSIFY_NO_REVERSE_SUFFIX, url + 7, - 1 - spare + 3 /* 10 - "file://" */, 0); - free(buffer); - return url; + memcpy(url, "file://", sizeof("file://")-1); + if (__unixify(buffer, __RISCOSIFY_NO_REVERSE_SUFFIX, + url + sizeof("file://")-1, + 1 - spare + 10 - (sizeof("file://")-1), + 0) == NULL) { + LOG(("__unixify failed: %s", buffer)); + free(buffer); + free(url); + return NULL; + } + free(buffer); buffer = NULL; + + /* We don't want '/' to be escaped. */ + url_err = url_escape(url, sizeof("file://")-1, false, "/", &escurl); + free(url); url = NULL; + if (url_err != URL_FUNC_OK) { + LOG(("url_escape failed: %s", url)); + return NULL; + } + + return escurl; } -- cgit v1.2.3