summaryrefslogtreecommitdiff
path: root/content/fetchcache.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-01-03 23:26:58 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-01-03 23:26:58 +0000
commitaa76fb175400f2a7791357fcdd83be49914c3892 (patch)
treef34e6495161a55bbd73a125b252041a5e827e4f4 /content/fetchcache.c
parentffb6153baaf57355171b5e715991fbde4bffdab0 (diff)
downloadnetsurf-aa76fb175400f2a7791357fcdd83be49914c3892.tar.gz
netsurf-aa76fb175400f2a7791357fcdd83be49914c3892.tar.bz2
[project @ 2006-01-03 23:26:58 by jmb]
Detect and prevent self-referential redirects. This is not a complete solution as it does not handle the likes of page1 -> page2 -> page1 -> ... To solve that probably requires counting the number of redirects a given fetch has made and then bailing once it exceeds some fixed value. From what I can see at present, this will have to be done at the top-level (i.e. browser_window_callback and suchlike). svn path=/import/netsurf/; revision=1978
Diffstat (limited to 'content/fetchcache.c')
-rw-r--r--content/fetchcache.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/content/fetchcache.c b/content/fetchcache.c
index c58d9d34f..a7e68ee97 100644
--- a/content/fetchcache.c
+++ b/content/fetchcache.c
@@ -307,8 +307,20 @@ void fetchcache_callback(fetch_msg msg, void *p, const char *data,
* destroyed in content_clean() */
c->status = CONTENT_STATUS_ERROR;
if (result == URL_FUNC_OK) {
- msg_data.redirect = url;
- content_broadcast(c, CONTENT_MSG_REDIRECT, msg_data);
+ /* check that we're not attempting to
+ * redirect to the same URL */
+ if (strcasecmp(c->url, url) == 0) {
+ msg_data.error =
+ messages_get("BadRedirect");
+ content_broadcast(c,
+ CONTENT_MSG_ERROR, msg_data);
+ }
+ else {
+ msg_data.redirect = url;
+ content_broadcast(c,
+ CONTENT_MSG_REDIRECT,
+ msg_data);
+ }
free(url);
} else {
msg_data.error = messages_get("BadRedirect");