From b1844cbf2a997ccf999286472ffc4d2c4bf79c1e Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 27 Sep 2020 14:20:14 +0100 Subject: split out about scheme query private handler --- content/fetchers/about/about.c | 192 ++++------------------------------------- 1 file changed, 15 insertions(+), 177 deletions(-) (limited to 'content/fetchers/about/about.c') diff --git a/content/fetchers/about/about.c b/content/fetchers/about/about.c index 1bc382b57..38ad57527 100644 --- a/content/fetchers/about/about.c +++ b/content/fetchers/about/about.c @@ -48,13 +48,15 @@ #include "desktop/system_colour.h" #include "private.h" +#include "query.h" +#include "about.h" #include "blank.h" #include "certificate.h" -#include "imagecache.h" -#include "atestament.h" #include "config.h" #include "choices.h" -#include "about.h" +#include "imagecache.h" +#include "query_privacy.h" +#include "atestament.h" typedef bool (*fetch_about_handler)(struct fetch_about_context *); @@ -219,13 +221,16 @@ nsurl *fetch_about_get_url(struct fetch_about_context *ctx) } -/** - * Generate a 500 server error respnse - * - * \param ctx The fetcher context. - * \return true if handled false if aborted. - */ -static bool fetch_about_srverror(struct fetch_about_context *ctx) +/* exported interface documented in about/private.h */ +const struct fetch_multipart_data * +fetch_about_get_multipart(struct fetch_about_context *ctx) +{ + return ctx->multipart; +} + + +/* exported interface documented in about/private.h */ +bool fetch_about_srverror(struct fetch_about_context *ctx) { nserror res; @@ -422,37 +427,6 @@ get_authentication_description(struct nsurl *url, } -/** - * generate a generic query description - */ -static nserror -get_query_description(struct nsurl *url, - const char *key, - char **out_str) -{ - nserror res; - char *url_s; - size_t url_l; - char *str = NULL; - - /* get the host in question */ - res = nsurl_get(url, NSURL_HOST, &url_s, &url_l); - if (res != NSERROR_OK) { - return res; - } - - /* obtain the description with the url substituted */ - str = messages_get_buff(key, url_s); - if (str == NULL) { - res = NSERROR_NOMEM; - } else { - *out_str = str; - } - - free(url_s); - - return res; -} /** @@ -621,142 +595,6 @@ fetch_about_query_auth_handler_aborted: } -/** - * Handler to generate about scheme privacy query page - * - * \param ctx The fetcher context. - * \return true if handled false if aborted. - */ -static bool fetch_about_query_privacy_handler(struct fetch_about_context *ctx) -{ - nserror res; - char *url_s; - size_t url_l; - const char *reason = ""; - const char *title; - struct nsurl *siteurl = NULL; - char *description = NULL; - const char *chainurl = NULL; - const struct fetch_multipart_data *curmd; /* mutipart data iterator */ - - /* extract parameters from multipart post data */ - curmd = ctx->multipart; - while (curmd != NULL) { - if (strcmp(curmd->name, "siteurl") == 0) { - res = nsurl_create(curmd->value, &siteurl); - if (res != NSERROR_OK) { - return fetch_about_srverror(ctx); - } - } else if (strcmp(curmd->name, "reason") == 0) { - reason = curmd->value; - } else if (strcmp(curmd->name, "chainurl") == 0) { - chainurl = curmd->value; - } - curmd = curmd->next; - } - - if (siteurl == NULL) { - return fetch_about_srverror(ctx); - } - - /* content is going to return ok */ - fetch_set_http_code(ctx->fetchh, 200); - - /* content type */ - if (fetch_about_send_header(ctx, "Content-Type: text/html; charset=utf-8")) { - goto fetch_about_query_ssl_handler_aborted; - } - - title = messages_get("PrivacyTitle"); - res = fetch_about_ssenddataf(ctx, - "\n\n" - "%s\n" - "\n" - "\n" - "\n" - "

%s

\n", - title, title); - if (res != NSERROR_OK) { - goto fetch_about_query_ssl_handler_aborted; - } - - res = fetch_about_ssenddataf(ctx, - "
"); - if (res != NSERROR_OK) { - goto fetch_about_query_ssl_handler_aborted; - } - - res = get_query_description(siteurl, - "PrivacyDescription", - &description); - if (res == NSERROR_OK) { - res = fetch_about_ssenddataf(ctx, "

%s

", description); - free(description); - if (res != NSERROR_OK) { - goto fetch_about_query_ssl_handler_aborted; - } - } - - if (chainurl == NULL) { - res = fetch_about_ssenddataf(ctx, - "

%s

" - "

%s

", - reason, - messages_get("ViewCertificatesNotPossible")); - } else { - res = fetch_about_ssenddataf(ctx, - "

%s

" - "

%s

", - reason, - chainurl, - messages_get("ViewCertificates")); - } - if (res != NSERROR_OK) { - goto fetch_about_query_ssl_handler_aborted; - } - res = fetch_about_ssenddataf(ctx, - "
" - "" - "" - "
", - messages_get("Backtosafety"), - messages_get("Proceed")); - if (res != NSERROR_OK) { - goto fetch_about_query_ssl_handler_aborted; - } - - res = nsurl_get(siteurl, NSURL_COMPLETE, &url_s, &url_l); - if (res != NSERROR_OK) { - url_s = strdup(""); - } - res = fetch_about_ssenddataf(ctx, - "", - url_s); - free(url_s); - if (res != NSERROR_OK) { - goto fetch_about_query_ssl_handler_aborted; - } - - res = fetch_about_ssenddataf(ctx, "
\n\n"); - if (res != NSERROR_OK) { - goto fetch_about_query_ssl_handler_aborted; - } - - fetch_about_send_finished(ctx); - - nsurl_unref(siteurl); - - return true; - -fetch_about_query_ssl_handler_aborted: - nsurl_unref(siteurl); - - return false; -} /** -- cgit v1.2.3