summaryrefslogtreecommitdiff
path: root/content/fetchers/about/about.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2020-09-27 14:20:14 +0100
committerVincent Sanders <vince@kyllikki.org>2020-09-27 23:09:56 +0100
commitb1844cbf2a997ccf999286472ffc4d2c4bf79c1e (patch)
tree7bcced07b6e6f64898184179a6778527200eacd1 /content/fetchers/about/about.c
parentff3b948ac0ee0142535bea9a6ebde57b7056c2eb (diff)
downloadnetsurf-b1844cbf2a997ccf999286472ffc4d2c4bf79c1e.tar.gz
netsurf-b1844cbf2a997ccf999286472ffc4d2c4bf79c1e.tar.bz2
split out about scheme query private handler
Diffstat (limited to 'content/fetchers/about/about.c')
-rw-r--r--content/fetchers/about/about.c192
1 files changed, 15 insertions, 177 deletions
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,
- "<html>\n<head>\n"
- "<title>%s</title>\n"
- "<link rel=\"stylesheet\" type=\"text/css\" "
- "href=\"resource:internal.css\">\n"
- "</head>\n"
- "<body class=\"ns-even-bg ns-even-fg ns-border\" id =\"privacy\">\n"
- "<h1 class=\"ns-border ns-odd-fg-bad\">%s</h1>\n",
- title, title);
- if (res != NSERROR_OK) {
- goto fetch_about_query_ssl_handler_aborted;
- }
-
- res = fetch_about_ssenddataf(ctx,
- "<form method=\"post\""
- " enctype=\"multipart/form-data\">");
- 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, "<div><p>%s</p></div>", description);
- free(description);
- if (res != NSERROR_OK) {
- goto fetch_about_query_ssl_handler_aborted;
- }
- }
-
- if (chainurl == NULL) {
- res = fetch_about_ssenddataf(ctx,
- "<div><p>%s</p></div>"
- "<div><p>%s</p></div>",
- reason,
- messages_get("ViewCertificatesNotPossible"));
- } else {
- res = fetch_about_ssenddataf(ctx,
- "<div><p>%s</p></div>"
- "<div><p><a href=\"%s\" target=\"_blank\">%s</a></p></div>",
- reason,
- chainurl,
- messages_get("ViewCertificates"));
- }
- if (res != NSERROR_OK) {
- goto fetch_about_query_ssl_handler_aborted;
- }
- res = fetch_about_ssenddataf(ctx,
- "<div id=\"buttons\">"
- "<input type=\"submit\" id=\"back\" name=\"back\" "
- "value=\"%s\" class=\"default-action\">"
- "<input type=\"submit\" id=\"proceed\" name=\"proceed\" "
- "value=\"%s\">"
- "</div>",
- 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,
- "<input type=\"hidden\" name=\"siteurl\" value=\"%s\">",
- url_s);
- free(url_s);
- if (res != NSERROR_OK) {
- goto fetch_about_query_ssl_handler_aborted;
- }
-
- res = fetch_about_ssenddataf(ctx, "</form></body>\n</html>\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;
-}
/**