From 4cbdcc4aae940065d027157c1bce2dbfc7d59c3b Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 22 Mar 2020 14:09:09 +0000 Subject: about: Add handling for unknown about: page Signed-off-by: Daniel Silverstone --- content/fetchers/about.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'content') diff --git a/content/fetchers/about.c b/content/fetchers/about.c index aa68fd2b1..e553cb43e 100644 --- a/content/fetchers/about.c +++ b/content/fetchers/about.c @@ -1792,6 +1792,28 @@ fetch_about_config_handler_aborted: return false; } +static bool +fetch_about_404_handler(struct fetch_about_context *ctx) +{ + nserror res; + + /* content is going to return 404 */ + fetch_set_http_code(ctx->fetchh, 404); + + /* content type */ + if (fetch_about_send_header(ctx, "Content-Type: text/plain; charset=utf-8")) { + return false; + } + + res = ssenddataf(ctx, "Unknown page: %s", nsurl_access(ctx->url)); + if (res != NSERROR_OK) { + return false; + } + + fetch_about_send_finished(ctx); + + return true; +} /** * callback to initialise the about scheme fetcher. @@ -1866,10 +1888,10 @@ fetch_about_setup(struct fetch *fetchh, for (handler_loop = 0; handler_loop < about_handler_list_len; handler_loop++) { - ctx->handler = about_handler_list[handler_loop].handler; if (lwc_string_isequal(path, about_handler_list[handler_loop].lname, &match) == lwc_error_ok && match) { + ctx->handler = about_handler_list[handler_loop].handler; break; } } @@ -1949,7 +1971,11 @@ static void fetch_about_poll(lwc_string *scheme) /* Only process non-aborted fetches */ if (c->aborted == false) { /* about fetches can be processed in one go */ - c->handler(c); + if (c->handler == NULL) { + fetch_about_404_handler(c); + } else { + c->handler(c); + } } /* And now finish */ -- cgit v1.2.3