Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/c238325b12318803a8dcc706d7d678333f82e1c8
...commit
http://git.netsurf-browser.org/netsurf.git/commit/c238325b12318803a8dcc706d7d678333f82e1c8
...tree
http://git.netsurf-browser.org/netsurf.git/tree/c238325b12318803a8dcc706d7d678333f82e1c8
The branch, master has been updated
via c238325b12318803a8dcc706d7d678333f82e1c8 (commit)
via a8889226126d85736da82c767abf705872c00d7e (commit)
from 5775e3941169952517eab741bb6e2262b48f6584 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c238325b12318803a8dcc706d7d678333f82e1c8
commit c238325b12318803a8dcc706d7d678333f82e1c8
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
add about scheme query handlers
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index 4e90f3a..7d0b3b9 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -31,10 +31,12 @@
#include <stdio.h>
#include <stdarg.h>
+#include "utils/log.h"
#include "testament.h"
#include "utils/corestrings.h"
#include "utils/nsoption.h"
#include "utils/utils.h"
+#include "utils/messages.h"
#include "utils/ring.h"
#include "content/fetch.h"
@@ -303,7 +305,9 @@ fetch_about_imagecache_handler_aborted:
return false;
}
-/** Handler to generate about:config page */
+/**
+ * Handler to generate about scheme config page
+ */
static bool fetch_about_config_handler(struct fetch_about_context *ctx)
{
fetch_msg msg;
@@ -587,6 +591,321 @@ static bool fetch_about_maps_handler(struct
fetch_about_context *ctx)
return true;
}
+
+/**
+ * generate a 500 server error respnse
+ */
+static bool fetch_about_srverror(struct fetch_about_context *ctx)
+{
+ char buffer[256];
+ int slen;
+ fetch_msg msg;
+
+ fetch_set_http_code(ctx->fetchh, 500);
+
+ /* content type */
+ if (fetch_about_send_header(ctx, "Content-Type: text/plain"))
+ return false;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+ slen = snprintf(buffer, sizeof buffer, "Server error 500");
+
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
+ return false;
+
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
+
+ return true;
+}
+
+
+/**
+ * generate the description of the login request
+ */
+static nserror
+get_login_description(struct nsurl *url,
+ const char *realm,
+ const char *username,
+ const char *password,
+ char **out_str)
+{
+ char *url_s;
+ size_t url_l;
+ nserror res;
+ char *str = NULL;
+ int slen;
+ const char *key;
+
+ res = nsurl_get(url, NSURL_SCHEME | NSURL_HOST, &url_s, &url_l);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ if ((*username == 0) && (*password == 0)) {
+ key = "LoginDescription";
+ } else {
+ key = "LoginAgain";
+ }
+
+ str = messages_get_buff(key, url_s, realm);
+ NSLOG(netsurf, INFO,
+ "key:%s url:%s realm:%s str:%s", key, url_s, realm, str);
+
+ if ((str != NULL) && (strcmp(key, str) != 0)) {
+ *out_str = str;
+ } else {
+ /* no message so fallback */
+ const char *fmt = "The site %s is requesting your username and
password. The realm is \"%s\"";
+ slen = snprintf(str, 0, fmt, url_s, realm) + 1;
+ str = malloc(slen);
+ if (str == NULL) {
+ res = NSERROR_NOMEM;
+ } else {
+ snprintf(str, slen, fmt, url_s, realm);
+ *out_str = str;
+ }
+ }
+
+ free(url_s);
+
+ return res;
+}
+
+
+/**
+ * Handler to generate about scheme authorisation query page
+ */
+static bool fetch_about_query_auth_handler(struct fetch_about_context *ctx)
+{
+ nserror res;
+ fetch_msg msg;
+ char buffer[1024];
+ int slen;
+ char *url_s;
+ size_t url_l;
+ const char *realm = "";
+ const char *username = "";
+ const char *password = "";
+ const char *title;
+ char *description = NULL;
+ struct nsurl *siteurl = 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, "realm") == 0) {
+ realm = curmd->value;
+ } else if (strcmp(curmd->name, "username") == 0) {
+ username = curmd->value;
+ } else if (strcmp(curmd->name, "password") == 0) {
+ password = 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_auth_handler_aborted;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+
+ title = messages_get("LoginTitle");
+ slen = snprintf(buffer, sizeof buffer,
+ "<html>\n<head>\n"
+ "<title>%s</title>\n"
+ "<link rel=\"stylesheet\" type=\"text/css\" "
+ "href=\"resource:internal.css\">\n"
+ "</head>\n"
+ "<body id =\"authentication\">\n"
+ "<h1>%s</h1>\n",
+ title, title);
+
+ res = get_login_description(siteurl,
+ realm,
+ username,
+ password,
+ &description);
+ if (res == NSERROR_OK) {
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<p>%s</p>",
+ description);
+ free(description);
+ }
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<form method=\"post\"
enctype=\"multipart/form-data\">");
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<div>"
+ "<label for=\"name\">%s:</label>"
+ "<input type=\"text\" id=\"username\" "
+ "name=\"username\" value=\"%s\">"
+ "</div>",
+ messages_get("Username"), username);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<div>"
+ "<label for=\"password\">%s:</label>"
+ "<input type=\"password\" id=\"password\" "
+ "name=\"password\" value=\"%s\">"
+ "</div>",
+ messages_get("Password"), password);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<div>"
+ "<input type=\"submit\" id=\"cancel\" name=\"cancel\" "
+ "value=\"%s\">"
+ "<input type=\"submit\" id=\"login\" name=\"login\" "
+ "value=\"%s\">"
+ "</div>",
+ messages_get("Cancel"),
+ messages_get("Login"));
+
+ res = nsurl_get(siteurl, NSURL_COMPLETE, &url_s, &url_l);
+ if (res != NSERROR_OK) {
+ url_s = strdup("");
+ }
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<input type=\"hidden\" name=\"siteurl\"
value=\"%s\">",
+ url_s);
+ free(url_s);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<input type=\"hidden\" name=\"realm\" value=\"%s\">",
+ realm);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "</form></body>\n</html>\n");
+
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
+ goto fetch_about_query_auth_handler_aborted;
+
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
+
+ return true;
+
+fetch_about_query_auth_handler_aborted:
+ return false;
+}
+
+/**
+ * Handler to generate about scheme ssl query page
+ */
+static bool fetch_about_query_ssl_handler(struct fetch_about_context *ctx)
+{
+ nserror res;
+ fetch_msg msg;
+ char buffer[1024];
+ int slen;
+ char *url_s;
+ size_t url_l;
+ const char *reason = "";
+ const char *title;
+ struct nsurl *siteurl = 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_ssl_handler_aborted;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+
+ title = messages_get("PrivacyTitle");
+ slen = snprintf(buffer, sizeof buffer,
+ "<html>\n<head>\n"
+ "<title>%s</title>\n"
+ "<link rel=\"stylesheet\" type=\"text/css\" "
+ "href=\"resource:internal.css\">\n"
+ "</head>\n"
+ "<body id =\"privacy\">\n"
+ "<h1>%s</h1>\n",
+ title, title);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<p>%s</p>",
+ reason);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<form method=\"post\"
enctype=\"multipart/form-data\">");
+
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<div>"
+ "<input type=\"submit\" id=\"back\" name=\"back\" "
+ "value=\"%s\">"
+ "<input type=\"submit\" id=\"proceed\"
name=\"proceed\" "
+ "value=\"%s\">"
+ "</div>",
+ messages_get("Backtosafety"),
+ messages_get("Proceed"));
+
+ res = nsurl_get(siteurl, NSURL_COMPLETE, &url_s, &url_l);
+ if (res != NSERROR_OK) {
+ url_s = strdup("");
+ }
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<input type=\"hidden\" name=\"siteurl\"
value=\"%s\">",
+ url_s);
+ free(url_s);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "</form></body>\n</html>\n");
+
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
+ goto fetch_about_query_ssl_handler_aborted;
+
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
+
+ return true;
+
+fetch_about_query_ssl_handler_aborted:
+ return false;
+}
+
+
/* Forward declaration because this handler requires the handler table. */
static bool fetch_about_about_handler(struct fetch_about_context *ctx);
@@ -679,6 +998,20 @@ struct about_handlers about_handler_list[] = {
NULL,
fetch_about_blank_handler,
true
+ },
+ {
+ "query/auth",
+ SLEN("query/auth"),
+ NULL,
+ fetch_about_query_auth_handler,
+ true
+ },
+ {
+ "query/ssl",
+ SLEN("query/ssl"),
+ NULL,
+ fetch_about_query_ssl_handler,
+ true
}
};
diff --git a/resources/FatMessages b/resources/FatMessages
index 6ac665c..3c6ca48 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -2740,8 +2740,12 @@ nl.all.CaseSens:Hoofdlettergevoelig
# This section contains tokens which are used in the 401 login
# (authentication) dialog box.
#
+en.all.LoginTitle:Authentication Requested
+fr.all.LoginTitle:Authentification demandée
en.all.LoginDescription:The site %s with realm "%s" is requesting credentials
for access.
+fr.all.LoginDescription:Le site %s avec le royaume "%s" demande des
informations d'identification pour l'accès.
en.all.LoginAgain:The credentials for the site %s and realm "%s" were rejected.
+fr.all.LoginAgain:Les identifiants pour le site %s et le royaume "%s" ont été
rejetés.
en.all.LoginLabel:A website is requesting credentials for access.
en.all.Host:Host
de.all.Host:Host
@@ -2775,8 +2779,16 @@ it.all.Cancel:Annulla
nl.all.Cancel:Annuleer
-# SSL certificate verification
-# ============================
+# Privacy error interface
+# =======================
+#
+
+en.all.PrivacyTitle:Privacy error
+en.all.Proceed:Proceed
+en.all.Backtosafety:Back to safety
+
+# SSL certificate viewer
+# ======================
#
# This section contains tokens which are used in the
# SSL certificate verification dialog box.
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=a8889226126d85736da82c767abf705872c00d7e
commit a8889226126d85736da82c767abf705872c00d7e
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
Improve about scheme doc comments and formatting
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index 4d14020..4e90f3a 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -47,7 +47,9 @@ struct fetch_about_context;
typedef bool (*fetch_about_handler)(struct fetch_about_context *);
-/** Context for an about fetch */
+/**
+ * Context for an about fetch
+ */
struct fetch_about_context {
struct fetch_about_context *r_next, *r_prev;
@@ -58,11 +60,24 @@ struct fetch_about_context {
nsurl *url; /**< The full url the fetch refers to */
+ const struct fetch_multipart_data *multipart; /**< post data */
+
fetch_about_handler handler;
};
static struct fetch_about_context *ring = NULL;
+/**
+ * handler info for about scheme
+ */
+struct about_handlers {
+ const char *name; /**< name to match in url */
+ int name_len;
+ lwc_string *lname; /**< Interned name */
+ fetch_about_handler handler; /**< handler for the url */
+ bool hidden; /**< If entry should be hidden in listing */
+};
+
/** issue fetch callbacks with locking */
static inline bool fetch_about_send_callback(const fetch_msg *msg,
struct fetch_about_context *ctx)
@@ -74,8 +89,8 @@ static inline bool fetch_about_send_callback(const fetch_msg
*msg,
return ctx->aborted;
}
-static bool fetch_about_send_header(struct fetch_about_context *ctx,
- const char *fmt, ...)
+static bool
+fetch_about_send_header(struct fetch_about_context *ctx, const char *fmt, ...)
{
char header[64];
fetch_msg msg;
@@ -575,42 +590,96 @@ static bool fetch_about_maps_handler(struct
fetch_about_context *ctx)
/* Forward declaration because this handler requires the handler table. */
static bool fetch_about_about_handler(struct fetch_about_context *ctx);
-struct about_handlers {
- const char *name; /**< name to match in url */
- int name_len;
- lwc_string *lname; /**< Interned name */
- fetch_about_handler handler; /* handler for the url */
- bool hidden; /* Flag indicating if entry should show in listing */
-};
-
-/** List of about paths and their handlers */
+/**
+ * List of about paths and their handlers
+ */
struct about_handlers about_handler_list[] = {
- { "credits", SLEN("credits"), NULL,
- fetch_about_credits_handler, false },
- { "licence", SLEN("licence"), NULL,
- fetch_about_licence_handler, false },
- { "license", SLEN("license"), NULL,
- fetch_about_licence_handler, true },
- { "welcome", SLEN("welcome"), NULL,
- fetch_about_welcome_handler, false },
- { "maps", SLEN("maps"), NULL,
- fetch_about_maps_handler, false },
- { "config", SLEN("config"), NULL,
- fetch_about_config_handler, false },
- { "Choices", SLEN("Choices"), NULL,
- fetch_about_choices_handler, false },
- { "testament", SLEN("testament"), NULL,
- fetch_about_testament_handler, false },
- { "about", SLEN("about"), NULL,
- fetch_about_about_handler, true },
- { "logo", SLEN("logo"), NULL,
- fetch_about_logo_handler, true },
- /* details about the image cache */
- { "imagecache", SLEN("imagecache"), NULL,
- fetch_about_imagecache_handler, true },
- /* The default blank page */
- { "blank", SLEN("blank"), NULL,
- fetch_about_blank_handler, true }
+ {
+ "credits",
+ SLEN("credits"),
+ NULL,
+ fetch_about_credits_handler,
+ false
+ },
+ {
+ "licence",
+ SLEN("licence"),
+ NULL,
+ fetch_about_licence_handler,
+ false
+ },
+ {
+ "license",
+ SLEN("license"),
+ NULL,
+ fetch_about_licence_handler,
+ true
+ },
+ {
+ "welcome",
+ SLEN("welcome"),
+ NULL,
+ fetch_about_welcome_handler,
+ false
+ },
+ {
+ "maps",
+ SLEN("maps"),
+ NULL,
+ fetch_about_maps_handler,
+ false
+ },
+ {
+ "config",
+ SLEN("config"),
+ NULL,
+ fetch_about_config_handler,
+ false
+ },
+ {
+ "Choices",
+ SLEN("Choices"),
+ NULL,
+ fetch_about_choices_handler,
+ false
+ },
+ {
+ "testament",
+ SLEN("testament"),
+ NULL,
+ fetch_about_testament_handler,
+ false
+ },
+ {
+ "about",
+ SLEN("about"),
+ NULL,
+ fetch_about_about_handler,
+ true
+ },
+ {
+ "logo",
+ SLEN("logo"),
+ NULL,
+ fetch_about_logo_handler,
+ true
+ },
+ {
+ /* details about the image cache */
+ "imagecache",
+ SLEN("imagecache"),
+ NULL,
+ fetch_about_imagecache_handler,
+ true
+ },
+ {
+ /* The default blank page */
+ "blank",
+ SLEN("blank"),
+ NULL,
+ fetch_about_blank_handler,
+ true
+ }
};
#define about_handler_list_len (sizeof(about_handler_list) / \
@@ -732,15 +801,22 @@ static bool fetch_about_can_fetch(const nsurl *url)
return true;
}
-/** callback to set up a about fetch context. */
+/**
+ * callback to set up a about scheme fetch.
+ *
+ * \param post_urlenc post data in urlenc format, owned by the llcache object
+ * hence valid the entire lifetime of the fetch.
+ * \param post_multipart post data in multipart format, owned by the llcache
+ * object hence valid the entire lifetime of the fetch.
+ */
static void *
fetch_about_setup(struct fetch *fetchh,
- nsurl *url,
- bool only_2xx,
- bool downgrade_tls,
- const char *post_urlenc,
- const struct fetch_multipart_data *post_multipart,
- const char **headers)
+ nsurl *url,
+ bool only_2xx,
+ bool downgrade_tls,
+ const char *post_urlenc,
+ const struct fetch_multipart_data *post_multipart,
+ const char **headers)
{
struct fetch_about_context *ctx;
unsigned int handler_loop;
@@ -769,6 +845,7 @@ fetch_about_setup(struct fetch *fetchh,
ctx->fetchh = fetchh;
ctx->url = nsurl_ref(url);
+ ctx->multipart = post_multipart;
RING_INSERT(ring, ctx);
-----------------------------------------------------------------------
Summary of changes:
content/fetchers/about.c | 502 +++++++++++++++++++++++++++++++++++++++++-----
resources/FatMessages | 16 +-
2 files changed, 470 insertions(+), 48 deletions(-)
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index 4d14020..7d0b3b9 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -31,10 +31,12 @@
#include <stdio.h>
#include <stdarg.h>
+#include "utils/log.h"
#include "testament.h"
#include "utils/corestrings.h"
#include "utils/nsoption.h"
#include "utils/utils.h"
+#include "utils/messages.h"
#include "utils/ring.h"
#include "content/fetch.h"
@@ -47,7 +49,9 @@ struct fetch_about_context;
typedef bool (*fetch_about_handler)(struct fetch_about_context *);
-/** Context for an about fetch */
+/**
+ * Context for an about fetch
+ */
struct fetch_about_context {
struct fetch_about_context *r_next, *r_prev;
@@ -58,11 +62,24 @@ struct fetch_about_context {
nsurl *url; /**< The full url the fetch refers to */
+ const struct fetch_multipart_data *multipart; /**< post data */
+
fetch_about_handler handler;
};
static struct fetch_about_context *ring = NULL;
+/**
+ * handler info for about scheme
+ */
+struct about_handlers {
+ const char *name; /**< name to match in url */
+ int name_len;
+ lwc_string *lname; /**< Interned name */
+ fetch_about_handler handler; /**< handler for the url */
+ bool hidden; /**< If entry should be hidden in listing */
+};
+
/** issue fetch callbacks with locking */
static inline bool fetch_about_send_callback(const fetch_msg *msg,
struct fetch_about_context *ctx)
@@ -74,8 +91,8 @@ static inline bool fetch_about_send_callback(const fetch_msg
*msg,
return ctx->aborted;
}
-static bool fetch_about_send_header(struct fetch_about_context *ctx,
- const char *fmt, ...)
+static bool
+fetch_about_send_header(struct fetch_about_context *ctx, const char *fmt, ...)
{
char header[64];
fetch_msg msg;
@@ -288,7 +305,9 @@ fetch_about_imagecache_handler_aborted:
return false;
}
-/** Handler to generate about:config page */
+/**
+ * Handler to generate about scheme config page
+ */
static bool fetch_about_config_handler(struct fetch_about_context *ctx)
{
fetch_msg msg;
@@ -572,45 +591,428 @@ static bool fetch_about_maps_handler(struct
fetch_about_context *ctx)
return true;
}
+
+/**
+ * generate a 500 server error respnse
+ */
+static bool fetch_about_srverror(struct fetch_about_context *ctx)
+{
+ char buffer[256];
+ int slen;
+ fetch_msg msg;
+
+ fetch_set_http_code(ctx->fetchh, 500);
+
+ /* content type */
+ if (fetch_about_send_header(ctx, "Content-Type: text/plain"))
+ return false;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+ slen = snprintf(buffer, sizeof buffer, "Server error 500");
+
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
+ return false;
+
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
+
+ return true;
+}
+
+
+/**
+ * generate the description of the login request
+ */
+static nserror
+get_login_description(struct nsurl *url,
+ const char *realm,
+ const char *username,
+ const char *password,
+ char **out_str)
+{
+ char *url_s;
+ size_t url_l;
+ nserror res;
+ char *str = NULL;
+ int slen;
+ const char *key;
+
+ res = nsurl_get(url, NSURL_SCHEME | NSURL_HOST, &url_s, &url_l);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ if ((*username == 0) && (*password == 0)) {
+ key = "LoginDescription";
+ } else {
+ key = "LoginAgain";
+ }
+
+ str = messages_get_buff(key, url_s, realm);
+ NSLOG(netsurf, INFO,
+ "key:%s url:%s realm:%s str:%s", key, url_s, realm, str);
+
+ if ((str != NULL) && (strcmp(key, str) != 0)) {
+ *out_str = str;
+ } else {
+ /* no message so fallback */
+ const char *fmt = "The site %s is requesting your username and
password. The realm is \"%s\"";
+ slen = snprintf(str, 0, fmt, url_s, realm) + 1;
+ str = malloc(slen);
+ if (str == NULL) {
+ res = NSERROR_NOMEM;
+ } else {
+ snprintf(str, slen, fmt, url_s, realm);
+ *out_str = str;
+ }
+ }
+
+ free(url_s);
+
+ return res;
+}
+
+
+/**
+ * Handler to generate about scheme authorisation query page
+ */
+static bool fetch_about_query_auth_handler(struct fetch_about_context *ctx)
+{
+ nserror res;
+ fetch_msg msg;
+ char buffer[1024];
+ int slen;
+ char *url_s;
+ size_t url_l;
+ const char *realm = "";
+ const char *username = "";
+ const char *password = "";
+ const char *title;
+ char *description = NULL;
+ struct nsurl *siteurl = 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, "realm") == 0) {
+ realm = curmd->value;
+ } else if (strcmp(curmd->name, "username") == 0) {
+ username = curmd->value;
+ } else if (strcmp(curmd->name, "password") == 0) {
+ password = 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_auth_handler_aborted;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+
+ title = messages_get("LoginTitle");
+ slen = snprintf(buffer, sizeof buffer,
+ "<html>\n<head>\n"
+ "<title>%s</title>\n"
+ "<link rel=\"stylesheet\" type=\"text/css\" "
+ "href=\"resource:internal.css\">\n"
+ "</head>\n"
+ "<body id =\"authentication\">\n"
+ "<h1>%s</h1>\n",
+ title, title);
+
+ res = get_login_description(siteurl,
+ realm,
+ username,
+ password,
+ &description);
+ if (res == NSERROR_OK) {
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<p>%s</p>",
+ description);
+ free(description);
+ }
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<form method=\"post\"
enctype=\"multipart/form-data\">");
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<div>"
+ "<label for=\"name\">%s:</label>"
+ "<input type=\"text\" id=\"username\" "
+ "name=\"username\" value=\"%s\">"
+ "</div>",
+ messages_get("Username"), username);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<div>"
+ "<label for=\"password\">%s:</label>"
+ "<input type=\"password\" id=\"password\" "
+ "name=\"password\" value=\"%s\">"
+ "</div>",
+ messages_get("Password"), password);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<div>"
+ "<input type=\"submit\" id=\"cancel\" name=\"cancel\" "
+ "value=\"%s\">"
+ "<input type=\"submit\" id=\"login\" name=\"login\" "
+ "value=\"%s\">"
+ "</div>",
+ messages_get("Cancel"),
+ messages_get("Login"));
+
+ res = nsurl_get(siteurl, NSURL_COMPLETE, &url_s, &url_l);
+ if (res != NSERROR_OK) {
+ url_s = strdup("");
+ }
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<input type=\"hidden\" name=\"siteurl\"
value=\"%s\">",
+ url_s);
+ free(url_s);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<input type=\"hidden\" name=\"realm\" value=\"%s\">",
+ realm);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "</form></body>\n</html>\n");
+
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
+ goto fetch_about_query_auth_handler_aborted;
+
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
+
+ return true;
+
+fetch_about_query_auth_handler_aborted:
+ return false;
+}
+
+/**
+ * Handler to generate about scheme ssl query page
+ */
+static bool fetch_about_query_ssl_handler(struct fetch_about_context *ctx)
+{
+ nserror res;
+ fetch_msg msg;
+ char buffer[1024];
+ int slen;
+ char *url_s;
+ size_t url_l;
+ const char *reason = "";
+ const char *title;
+ struct nsurl *siteurl = 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_ssl_handler_aborted;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+
+ title = messages_get("PrivacyTitle");
+ slen = snprintf(buffer, sizeof buffer,
+ "<html>\n<head>\n"
+ "<title>%s</title>\n"
+ "<link rel=\"stylesheet\" type=\"text/css\" "
+ "href=\"resource:internal.css\">\n"
+ "</head>\n"
+ "<body id =\"privacy\">\n"
+ "<h1>%s</h1>\n",
+ title, title);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<p>%s</p>",
+ reason);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<form method=\"post\"
enctype=\"multipart/form-data\">");
+
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<div>"
+ "<input type=\"submit\" id=\"back\" name=\"back\" "
+ "value=\"%s\">"
+ "<input type=\"submit\" id=\"proceed\"
name=\"proceed\" "
+ "value=\"%s\">"
+ "</div>",
+ messages_get("Backtosafety"),
+ messages_get("Proceed"));
+
+ res = nsurl_get(siteurl, NSURL_COMPLETE, &url_s, &url_l);
+ if (res != NSERROR_OK) {
+ url_s = strdup("");
+ }
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "<input type=\"hidden\" name=\"siteurl\"
value=\"%s\">",
+ url_s);
+ free(url_s);
+
+ slen += snprintf(buffer + slen, sizeof(buffer) - slen,
+ "</form></body>\n</html>\n");
+
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
+ goto fetch_about_query_ssl_handler_aborted;
+
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
+
+ return true;
+
+fetch_about_query_ssl_handler_aborted:
+ return false;
+}
+
+
/* Forward declaration because this handler requires the handler table. */
static bool fetch_about_about_handler(struct fetch_about_context *ctx);
-struct about_handlers {
- const char *name; /**< name to match in url */
- int name_len;
- lwc_string *lname; /**< Interned name */
- fetch_about_handler handler; /* handler for the url */
- bool hidden; /* Flag indicating if entry should show in listing */
-};
-
-/** List of about paths and their handlers */
+/**
+ * List of about paths and their handlers
+ */
struct about_handlers about_handler_list[] = {
- { "credits", SLEN("credits"), NULL,
- fetch_about_credits_handler, false },
- { "licence", SLEN("licence"), NULL,
- fetch_about_licence_handler, false },
- { "license", SLEN("license"), NULL,
- fetch_about_licence_handler, true },
- { "welcome", SLEN("welcome"), NULL,
- fetch_about_welcome_handler, false },
- { "maps", SLEN("maps"), NULL,
- fetch_about_maps_handler, false },
- { "config", SLEN("config"), NULL,
- fetch_about_config_handler, false },
- { "Choices", SLEN("Choices"), NULL,
- fetch_about_choices_handler, false },
- { "testament", SLEN("testament"), NULL,
- fetch_about_testament_handler, false },
- { "about", SLEN("about"), NULL,
- fetch_about_about_handler, true },
- { "logo", SLEN("logo"), NULL,
- fetch_about_logo_handler, true },
- /* details about the image cache */
- { "imagecache", SLEN("imagecache"), NULL,
- fetch_about_imagecache_handler, true },
- /* The default blank page */
- { "blank", SLEN("blank"), NULL,
- fetch_about_blank_handler, true }
+ {
+ "credits",
+ SLEN("credits"),
+ NULL,
+ fetch_about_credits_handler,
+ false
+ },
+ {
+ "licence",
+ SLEN("licence"),
+ NULL,
+ fetch_about_licence_handler,
+ false
+ },
+ {
+ "license",
+ SLEN("license"),
+ NULL,
+ fetch_about_licence_handler,
+ true
+ },
+ {
+ "welcome",
+ SLEN("welcome"),
+ NULL,
+ fetch_about_welcome_handler,
+ false
+ },
+ {
+ "maps",
+ SLEN("maps"),
+ NULL,
+ fetch_about_maps_handler,
+ false
+ },
+ {
+ "config",
+ SLEN("config"),
+ NULL,
+ fetch_about_config_handler,
+ false
+ },
+ {
+ "Choices",
+ SLEN("Choices"),
+ NULL,
+ fetch_about_choices_handler,
+ false
+ },
+ {
+ "testament",
+ SLEN("testament"),
+ NULL,
+ fetch_about_testament_handler,
+ false
+ },
+ {
+ "about",
+ SLEN("about"),
+ NULL,
+ fetch_about_about_handler,
+ true
+ },
+ {
+ "logo",
+ SLEN("logo"),
+ NULL,
+ fetch_about_logo_handler,
+ true
+ },
+ {
+ /* details about the image cache */
+ "imagecache",
+ SLEN("imagecache"),
+ NULL,
+ fetch_about_imagecache_handler,
+ true
+ },
+ {
+ /* The default blank page */
+ "blank",
+ SLEN("blank"),
+ NULL,
+ fetch_about_blank_handler,
+ true
+ },
+ {
+ "query/auth",
+ SLEN("query/auth"),
+ NULL,
+ fetch_about_query_auth_handler,
+ true
+ },
+ {
+ "query/ssl",
+ SLEN("query/ssl"),
+ NULL,
+ fetch_about_query_ssl_handler,
+ true
+ }
};
#define about_handler_list_len (sizeof(about_handler_list) / \
@@ -732,15 +1134,22 @@ static bool fetch_about_can_fetch(const nsurl *url)
return true;
}
-/** callback to set up a about fetch context. */
+/**
+ * callback to set up a about scheme fetch.
+ *
+ * \param post_urlenc post data in urlenc format, owned by the llcache object
+ * hence valid the entire lifetime of the fetch.
+ * \param post_multipart post data in multipart format, owned by the llcache
+ * object hence valid the entire lifetime of the fetch.
+ */
static void *
fetch_about_setup(struct fetch *fetchh,
- nsurl *url,
- bool only_2xx,
- bool downgrade_tls,
- const char *post_urlenc,
- const struct fetch_multipart_data *post_multipart,
- const char **headers)
+ nsurl *url,
+ bool only_2xx,
+ bool downgrade_tls,
+ const char *post_urlenc,
+ const struct fetch_multipart_data *post_multipart,
+ const char **headers)
{
struct fetch_about_context *ctx;
unsigned int handler_loop;
@@ -769,6 +1178,7 @@ fetch_about_setup(struct fetch *fetchh,
ctx->fetchh = fetchh;
ctx->url = nsurl_ref(url);
+ ctx->multipart = post_multipart;
RING_INSERT(ring, ctx);
diff --git a/resources/FatMessages b/resources/FatMessages
index 6ac665c..3c6ca48 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -2740,8 +2740,12 @@ nl.all.CaseSens:Hoofdlettergevoelig
# This section contains tokens which are used in the 401 login
# (authentication) dialog box.
#
+en.all.LoginTitle:Authentication Requested
+fr.all.LoginTitle:Authentification demandée
en.all.LoginDescription:The site %s with realm "%s" is requesting credentials
for access.
+fr.all.LoginDescription:Le site %s avec le royaume "%s" demande des
informations d'identification pour l'accès.
en.all.LoginAgain:The credentials for the site %s and realm "%s" were rejected.
+fr.all.LoginAgain:Les identifiants pour le site %s et le royaume "%s" ont été
rejetés.
en.all.LoginLabel:A website is requesting credentials for access.
en.all.Host:Host
de.all.Host:Host
@@ -2775,8 +2779,16 @@ it.all.Cancel:Annulla
nl.all.Cancel:Annuleer
-# SSL certificate verification
-# ============================
+# Privacy error interface
+# =======================
+#
+
+en.all.PrivacyTitle:Privacy error
+en.all.Proceed:Proceed
+en.all.Backtosafety:Back to safety
+
+# SSL certificate viewer
+# ======================
#
# This section contains tokens which are used in the
# SSL certificate verification dialog box.
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org