diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-03-22 14:09:09 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-03-22 14:09:09 +0000 |
commit | 4cbdcc4aae940065d027157c1bce2dbfc7d59c3b (patch) | |
tree | b266b5b676b9dc38289168ff7198079d8bc5d9e7 | |
parent | 9014dc738114d23d9b1c819e9a832b4a3e5571d5 (diff) | |
download | netsurf-4cbdcc4aae940065d027157c1bce2dbfc7d59c3b.tar.gz netsurf-4cbdcc4aae940065d027157c1bce2dbfc7d59c3b.tar.bz2 |
about: Add handling for unknown about: page
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r-- | content/fetchers/about.c | 30 |
1 files changed, 28 insertions, 2 deletions
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 */ |