diff options
Diffstat (limited to 'frontends/riscos/gui.c')
-rw-r--r-- | frontends/riscos/gui.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c index 72eeb6282..7c5216462 100644 --- a/frontends/riscos/gui.c +++ b/frontends/riscos/gui.c @@ -1405,7 +1405,7 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out) int spare; char *canonical_path; /* canonicalised RISC OS path */ char *unix_path; /* unix path */ - char *escurl; + char *escaped_path; os_error *error; nserror ret; int urllen; @@ -1443,31 +1443,34 @@ static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out) } free(canonical_path); - /* convert the unix path into a url */ - urllen = strlen(unix_path) + FILE_SCHEME_PREFIX_LEN + 1; + /* url escape the unix path */ + ret = url_escape(unix_path, false, "/", &escaped_path); + if (ret != NSERROR_OK) { + free(unix_path); + return ret; + } + free(unix_path); + + /* convert the escaped unix path into a url */ + urllen = strlen(escaped_path) + FILE_SCHEME_PREFIX_LEN + 1; url = malloc(urllen); if (url == NULL) { LOG("Unable to allocate url"); - free(unix_path); + free(escaped_path); return NSERROR_NOMEM; } - if (*unix_path == '/') { - snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, unix_path + 1); + if (*escaped_path == '/') { + snprintf(url, urllen, "%s%s", + FILE_SCHEME_PREFIX, escaped_path + 1); } else { - snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, unix_path); + snprintf(url, urllen, "%s%s", + FILE_SCHEME_PREFIX, escaped_path); } - free(unix_path); + free(escaped_path); - /* We don't want '/' to be escaped. */ - ret = url_escape(url, FILE_SCHEME_PREFIX_LEN, false, "/", &escurl); + ret = nsurl_create(url, url_out); free(url); - if (ret != NSERROR_OK) { - return ret; - } - - ret = nsurl_create(escurl, url_out); - free(escurl); return ret; } |