g_object_unref(cookie);
#endif
#ifdef FEATURE_HSTS
- HSTSProvider *hsts = hsts_provider_new();
- soup_session_add_feature(vb.session, SOUP_SESSION_FEATURE(hsts));
- g_object_unref(hsts);
+ /* create only the session feature - the feature is added in setting.c
+ * when the setting hsts=on */
+ vb.config.hsts_provider = hsts_provider_new();
#endif
}
static void session_cleanup(void)
{
#ifdef FEATURE_HSTS
- /* remove feature from session to make sure the feature is finalized */
+ /* remove feature from session and unref the feature to make sure the
+ * feature is finalized */
+ g_object_unref(vb.config.hsts_provider);
soup_session_remove_feature_by_type(vb.session, HSTS_TYPE_PROVIDER);
#endif
}
#include "util.h"
#include "completion.h"
#include "js.h"
+#ifdef FEATURE_HSTS
+#include "hsts.h"
+#endif
static GHashTable *settings;
static SettingStatus headers(const Setting *s, const SettingType type);
static SettingStatus nextpattern(const Setting *s, const SettingType type);
static SettingStatus fullscreen(const Setting *s, const SettingType type);
+#ifdef FEATURE_HSTS
+static SettingStatus hsts(const Setting *s, const SettingType type);
+#endif
static gboolean validate_js_regexp_list(const char *pattern);
{NULL, "nextpattern", TYPE_CHAR, nextpattern, {.s = "/\\bnext\\b/i,/^(>\\|>>\\|»)$/,/^(>\\|>>\\|»)/,/(>\\|>>\\|»)$/,/\\bmore\\b/i"}},
{NULL, "previouspattern", TYPE_CHAR, nextpattern, {.s = "/\\bprev\\|previous\\b/i,/^(<\\|<<\\|«)$/,/^(<\\|<<\\|«)/,/(<\\|<<\\|«)$/"}},
{NULL, "fullscreen", TYPE_BOOLEAN, fullscreen, {.i = 0}},
+#ifdef FEATURE_HSTS
+ {NULL, "hsts", TYPE_BOOLEAN, hsts, {.i = 1}},
+#endif
};
void setting_init(void)
return SETTING_OK;
}
+#ifdef FEATURE_HSTS
+static SettingStatus hsts(const Setting *s, const SettingType type)
+{
+ gboolean active;
+ if (type == SETTING_GET) {
+ active = soup_session_has_feature(vb.session, HSTS_TYPE_PROVIDER);
+ print_value(s, &active);
+
+ return SETTING_OK;
+ }
+
+ if (type == SETTING_TOGGLE) {
+ active = !soup_session_has_feature(vb.session, HSTS_TYPE_PROVIDER);
+ print_value(s, &active);
+ } else {
+ active = (s->arg.i != 0);
+ }
+
+ if (active) {
+ soup_session_add_feature(vb.session, SOUP_SESSION_FEATURE(vb.config.hsts_provider));
+ } else {
+ soup_session_remove_feature(vb.session, SOUP_SESSION_FEATURE(vb.config.hsts_provider));
+ }
+ return SETTING_OK;
+}
+#endif
+
/**
* Validated syntax given list of JavaScript RegExp patterns.
* If validation fails, the error is shown to the user.