diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2006-04-12 08:09:27 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2006-04-12 08:09:27 +0000 |
commit | ef301b861982818e140b1f17b8ec5f71ce5b4f64 (patch) | |
tree | 903742a91a427166138502d387c84cd4e12ca7d6 /content/fetchcache.c | |
parent | 4ecbfb483c96ea6f994dfc0aaab6e82aec8e7aa4 (diff) | |
download | netsurf-ef301b861982818e140b1f17b8ec5f71ce5b4f64.tar.gz netsurf-ef301b861982818e140b1f17b8ec5f71ce5b4f64.tar.bz2 |
Fix URL file loading and add support for file:/// URLs to urldb
Convert file:/... to file:///... (the former isn't a valid URL)
svn path=/trunk/netsurf/; revision=2524
Diffstat (limited to 'content/fetchcache.c')
-rw-r--r-- | content/fetchcache.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/content/fetchcache.c b/content/fetchcache.c index bc8907f14..eb47f332a 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -82,8 +82,35 @@ struct content * fetchcache(const char *url, char *etag = 0; time_t date = 0; - if ((url1 = strdup(url)) == NULL) - return NULL; + if (strncasecmp(url, "file:///", 8) && + strncasecmp(url, "file:/", 6) == 0) { + /* Manipulate file URLs into correct format */ + if (strncasecmp(url, "file://", 7) == 0) { + /* file://host/... */ + char *slash = 0; + + url1 = malloc(7 + strlen(url)); + if (!url1) + return NULL; + + strcpy(url1, "file://"); + slash = strchr(url + 7, '/'); + if (slash) + strcat(url1 + 7, slash); + } else { + /* file:/... */ + url1 = malloc(7 + strlen(url)); + if (!url1) + return NULL; + + strcpy(url1, "file://"); + strcat(url1 + 7, url + 5); + } + } else { + /* simply duplicate the URL */ + if ((url1 = strdup(url)) == NULL) + return NULL; + } /* strip fragment identifier */ if ((hash = strchr(url1, '#')) != NULL) |