From ef301b861982818e140b1f17b8ec5f71ce5b4f64 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 12 Apr 2006 08:09:27 +0000 Subject: 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 --- content/fetchcache.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'content/fetchcache.c') 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) -- cgit v1.2.3