summaryrefslogtreecommitdiff
path: root/content/fetchcache.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-08-06 17:51:23 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-08-06 17:51:23 +0000
commit89f760a3e78d4235b310552900e23e483ea1b551 (patch)
tree4906a6b2088602712bb82ce7884078d100ec7bec /content/fetchcache.c
parent4d8c68583fdea1b32f884e02e890e9f75ab19b14 (diff)
downloadnetsurf-89f760a3e78d4235b310552900e23e483ea1b551.tar.gz
netsurf-89f760a3e78d4235b310552900e23e483ea1b551.tar.bz2
Detect attempted fetches using protocols we can't handle.
Mark content in error in a couple of cases that I'd missed ages ago. svn path=/trunk/netsurf/; revision=2816
Diffstat (limited to 'content/fetchcache.c')
-rw-r--r--content/fetchcache.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/content/fetchcache.c b/content/fetchcache.c
index 1d0018d97..009dd8021 100644
--- a/content/fetchcache.c
+++ b/content/fetchcache.c
@@ -222,7 +222,39 @@ void fetchcache_go(struct content *content, char *referer,
LOG(("url %s, status %s", content->url,
content_status_name[content->status]));
- if (content->status == CONTENT_STATUS_TYPE_UNKNOWN && content->fetch) {
+ /* We may well have been asked to fetch an URL using a protocol
+ * that we can't support. Check for this here and, if we can't
+ * perform the fetch, notify the caller and exit */
+ if (!fetch_can_fetch(content->url)) {
+
+ /* The only case where this should fail is if we're a
+ * brand new content with no active fetch. If we're not,
+ * another content with the same URL somehow got through
+ * the fetch_can_fetch check. That should be impossible.
+ */
+ assert(content->status == CONTENT_STATUS_TYPE_UNKNOWN &&
+ !content->fetch);
+
+ snprintf(error_message, sizeof error_message,
+ messages_get("InvalidURL"),
+ content->url);
+
+ if (content->no_error_pages) {
+ /* Mark as in error so content is destroyed
+ * on cache clean */
+ content->status = CONTENT_STATUS_ERROR;
+ msg_data.error = error_message;
+ callback(CONTENT_MSG_ERROR,
+ content, p1, p2, msg_data);
+ } else {
+ fetchcache_error_page(content, error_message);
+ }
+
+ return;
+ }
+
+ if (content->status == CONTENT_STATUS_TYPE_UNKNOWN &&
+ content->fetch) {
/* fetching, but not yet received any response:
* no action required */
@@ -236,7 +268,7 @@ void fetchcache_go(struct content *content, char *referer,
content->cache_data->date = 0;
headers = malloc(3 * sizeof(char *));
if (!headers) {
- talloc_free(etag);
+ content->status = CONTENT_STATUS_ERROR;
msg_data.error = messages_get("NoMemory");
callback(CONTENT_MSG_ERROR, content, p1, p2,
msg_data);
@@ -246,7 +278,7 @@ void fetchcache_go(struct content *content, char *referer,
headers[i] = malloc(15 + strlen(etag) + 1);
if (!headers[i]) {
free(headers);
- talloc_free(etag);
+ content->status = CONTENT_STATUS_ERROR;
msg_data.error = messages_get("NoMemory");
callback(CONTENT_MSG_ERROR, content, p1, p2,
msg_data);
@@ -262,6 +294,7 @@ void fetchcache_go(struct content *content, char *referer,
free(headers[i]);
}
free(headers);
+ content->status = CONTENT_STATUS_ERROR;
msg_data.error = messages_get("NoMemory");
callback(CONTENT_MSG_ERROR, content, p1, p2,
msg_data);
@@ -318,7 +351,6 @@ void fetchcache_go(struct content *content, char *referer,
/* shouldn't usually occur */
msg_data.error = messages_get("MiscError");
callback(CONTENT_MSG_ERROR, content, p1, p2, msg_data);
-
}
}