diff options
author | portix <portix@gmx.net> | 2011-12-29 12:26:14 +0100 |
---|---|---|
committer | portix <portix@gmx.net> | 2011-12-29 12:26:14 +0100 |
commit | 869bfe14aaae072916fd27536170b1256452c836 (patch) | |
tree | 8374dcfd7e823c15c784d73cec0d6076a6c7f3f5 /src/commands.c | |
parent | 8e97425397b2c1042059f9a8e9659fc0ae5c0f18 (diff) | |
download | dwb-869bfe14aaae072916fd27536170b1256452c836.zip |
Introducing a whitelist for session cookies; new command allow_session_cookie
--HG--
branch : experimental
Diffstat (limited to 'src/commands.c')
-rw-r--r-- | src/commands.c | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/src/commands.c b/src/commands.c index 92d46ab2..dced57c3 100644 --- a/src/commands.c +++ b/src/commands.c @@ -210,46 +210,11 @@ commands_show_settings(KeyMap *km, Arg *arg) { /* commands_allow_cookie {{{*/ DwbStatus commands_allow_cookie(KeyMap *km, Arg *arg) { - GSList *asked = NULL, *allowed = NULL; - int length; - GSList *last_cookies = dwb_soup_get_last_cookies(); - if (last_cookies) { - GString *buffer = g_string_new(NULL); - for (GSList *l = last_cookies; l; l=l->next) { - SoupCookie *c = l->data; - const char *domain = soup_cookie_get_domain(c); - if ( ! dwb.fc.cookies_allow || g_list_find_custom(dwb.fc.cookies_allow, domain, (GCompareFunc) g_strcmp0) == NULL ) { - /* only ask once, if it was already prompted for this domain and allowed it will be handled - * in the else clause */ - if (g_slist_find_custom(asked, domain, (GCompareFunc)g_strcmp0)) - continue; - if (dwb_confirm(dwb.state.fview, "Allow cookies for domain %s [y/n]", domain)) { - dwb.fc.cookies_allow = g_list_append(dwb.fc.cookies_allow, g_strdup(domain)); - util_file_add(dwb.files.cookies_allow, domain, true, -1); - g_string_append_printf(buffer, "%s ", domain); - allowed = g_slist_prepend(allowed, soup_cookie_copy(c)); - } - asked = g_slist_prepend(asked, (char*)domain); - CLEAR_COMMAND_TEXT(); - } - else { - allowed = g_slist_prepend(allowed, soup_cookie_copy(c)); - } - } - dwb_soup_save_cookies(allowed); - length = g_slist_length(allowed); - if (length > 0) { - dwb_set_normal_message(dwb.state.fview, true, "Allowed domain%s: %s", length == 1 ? "" : "s", buffer->str); - } - g_string_free(buffer, true); - g_slist_free(asked); - /* The cookies must not be freed, the are stolen by the cookiejar */ - g_slist_free(allowed); - - soup_cookies_free(last_cookies); - return STATUS_OK; - } - return STATUS_ERROR; + if (arg->n == COOKIE_ALLOW_PERSISTENT) + dwb.fc.cookies_allow = dwb_soup_allow_cookie(dwb.fc.cookies_allow, dwb.files.cookies_allow, arg->n); + else + dwb.fc.cookies_session_allow = dwb_soup_allow_cookie(dwb.fc.cookies_session_allow, dwb.files.cookies_session_allow, arg->n); + return STATUS_OK; }/*}}}*/ /* commands_bookmark {{{*/ |