summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/fetchers/about/Makefile1
-rw-r--r--content/fetchers/about/about.c126
-rw-r--r--content/fetchers/about/query_fetcherror.c158
-rw-r--r--content/fetchers/about/query_fetcherror.h35
4 files changed, 195 insertions, 125 deletions
diff --git a/content/fetchers/about/Makefile b/content/fetchers/about/Makefile
index 529141830..da271097c 100644
--- a/content/fetchers/about/Makefile
+++ b/content/fetchers/about/Makefile
@@ -9,6 +9,7 @@ S_FETCHER_ABOUT := \
imagecache.c \
query.c \
query_auth.c \
+ query_fetcherror.c \
query_privacy.c \
query_timeout.c \
testament.c
diff --git a/content/fetchers/about/about.c b/content/fetchers/about/about.c
index d1547ae13..bb9d68273 100644
--- a/content/fetchers/about/about.c
+++ b/content/fetchers/about/about.c
@@ -56,6 +56,7 @@
#include "imagecache.h"
#include "query.h"
#include "query_auth.h"
+#include "query_fetcherror.h"
#include "query_privacy.h"
#include "query_timeout.h"
#include "atestament.h"
@@ -386,131 +387,6 @@ static bool fetch_about_welcome_handler(struct fetch_about_context *ctx)
}
-
-
-/**
- * Handler to generate about scheme fetch error query page
- *
- * \param ctx The fetcher context.
- * \return true if handled false if aborted.
- */
-static bool
-fetch_about_query_fetcherror_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 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;
- }
- 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_fetcherror_handler_aborted;
- }
-
- title = messages_get("FetchErrorTitle");
- 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 =\"fetcherror\">\n"
- "<h1 class=\"ns-border ns-odd-fg-bad\">%s</h1>\n",
- title, title);
- if (res != NSERROR_OK) {
- goto fetch_about_query_fetcherror_handler_aborted;
- }
-
- res = fetch_about_ssenddataf(ctx,
- "<form method=\"post\""
- " enctype=\"multipart/form-data\">");
- if (res != NSERROR_OK) {
- goto fetch_about_query_fetcherror_handler_aborted;
- }
-
- res = get_query_description(siteurl,
- "FetchErrorDescription",
- &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_fetcherror_handler_aborted;
- }
- }
- res = fetch_about_ssenddataf(ctx, "<div><p>%s</p></div>", reason);
- if (res != NSERROR_OK) {
- goto fetch_about_query_fetcherror_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=\"retry\" name=\"retry\" "
- "value=\"%s\">"
- "</div>",
- messages_get("Backtoprevious"),
- messages_get("TryAgain"));
- if (res != NSERROR_OK) {
- goto fetch_about_query_fetcherror_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_fetcherror_handler_aborted;
- }
-
- res = fetch_about_ssenddataf(ctx, "</form></body>\n</html>\n");
- if (res != NSERROR_OK) {
- goto fetch_about_query_fetcherror_handler_aborted;
- }
-
- fetch_about_send_finished(ctx);
-
- nsurl_unref(siteurl);
-
- return true;
-
-fetch_about_query_fetcherror_handler_aborted:
- nsurl_unref(siteurl);
-
- return false;
-}
-
-
/* Forward declaration because this handler requires the handler table. */
static bool fetch_about_about_handler(struct fetch_about_context *ctx);
diff --git a/content/fetchers/about/query_fetcherror.c b/content/fetchers/about/query_fetcherror.c
new file mode 100644
index 000000000..010a597e4
--- /dev/null
+++ b/content/fetchers/about/query_fetcherror.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2020 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf.
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * content generator for the about scheme query privacy page
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "utils/errors.h"
+#include "utils/messages.h"
+#include "content/fetch.h"
+
+#include "private.h"
+#include "query.h"
+#include "query_fetcherror.h"
+
+/**
+ * Handler to generate about scheme fetch error query page
+ *
+ * \param ctx The fetcher context.
+ * \return true if handled false if aborted.
+ */
+bool fetch_about_query_fetcherror_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 struct fetch_multipart_data *curmd; /* mutipart data iterator */
+
+ /* extract parameters from multipart post data */
+ curmd = fetch_about_get_multipart(ctx);
+ 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;
+ }
+ curmd = curmd->next;
+ }
+
+ if (siteurl == NULL) {
+ return fetch_about_srverror(ctx);
+ }
+
+ /* content is going to return ok */
+ fetch_about_set_http_code(ctx, 200);
+
+ /* content type */
+ if (fetch_about_send_header(ctx, "Content-Type: text/html; charset=utf-8")) {
+ goto fetch_about_query_fetcherror_handler_aborted;
+ }
+
+ title = messages_get("FetchErrorTitle");
+ 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 =\"fetcherror\">\n"
+ "<h1 class=\"ns-border ns-odd-fg-bad\">%s</h1>\n",
+ title, title);
+ if (res != NSERROR_OK) {
+ goto fetch_about_query_fetcherror_handler_aborted;
+ }
+
+ res = fetch_about_ssenddataf(ctx,
+ "<form method=\"post\""
+ " enctype=\"multipart/form-data\">");
+ if (res != NSERROR_OK) {
+ goto fetch_about_query_fetcherror_handler_aborted;
+ }
+
+ res = get_query_description(siteurl,
+ "FetchErrorDescription",
+ &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_fetcherror_handler_aborted;
+ }
+ }
+ res = fetch_about_ssenddataf(ctx, "<div><p>%s</p></div>", reason);
+ if (res != NSERROR_OK) {
+ goto fetch_about_query_fetcherror_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=\"retry\" name=\"retry\" "
+ "value=\"%s\">"
+ "</div>",
+ messages_get("Backtoprevious"),
+ messages_get("TryAgain"));
+ if (res != NSERROR_OK) {
+ goto fetch_about_query_fetcherror_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_fetcherror_handler_aborted;
+ }
+
+ res = fetch_about_ssenddataf(ctx, "</form></body>\n</html>\n");
+ if (res != NSERROR_OK) {
+ goto fetch_about_query_fetcherror_handler_aborted;
+ }
+
+ fetch_about_send_finished(ctx);
+
+ nsurl_unref(siteurl);
+
+ return true;
+
+fetch_about_query_fetcherror_handler_aborted:
+ nsurl_unref(siteurl);
+
+ return false;
+}
diff --git a/content/fetchers/about/query_fetcherror.h b/content/fetchers/about/query_fetcherror.h
new file mode 100644
index 000000000..85d972f8e
--- /dev/null
+++ b/content/fetchers/about/query_fetcherror.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2020 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf.
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * about scheme query fetch error handler interface
+ */
+
+#ifndef NETSURF_CONTENT_FETCHERS_ABOUT_QUERY_FETCHERROR_H
+#define NETSURF_CONTENT_FETCHERS_ABOUT_QUERY_FETCHERROR_H
+
+/**
+ * Handler to generate about scheme fetch error query page
+ *
+ * \param ctx The fetcher context.
+ * \return true if handled false if aborted.
+ */
+bool fetch_about_query_fetcherror_handler(struct fetch_about_context *ctx);
+
+#endif