diff -r dbb565b8d61c surf.c --- a/surf.c Fri Jun 25 09:42:58 2010 +0200 +++ b/surf.c Sat Jun 26 22:00:34 2010 -0400 @@ -140,6 +140,7 @@ while(clients) destroyclient(clients); g_free(cookiefile); + g_free(cookiewlist); g_free(scriptfile); g_free(stylefile); } @@ -317,12 +318,33 @@ gotheaders(SoupMessage *msg, gpointer v) { SoupURI *uri; GSList *l, *p; + char line [256]; + + FILE *cwl = fopen(cookiewlist,"r"); uri = soup_message_get_uri(msg); for(p = l = soup_cookies_from_response(msg); p; p = g_slist_next(p)) { - setcookie((SoupCookie *)p->data); + + /* Cookie whitelisting */ + /* Domains can be max 255 octets/chars long */ + printf("Checking cookie: %s\n",((SoupCookie *)p->data)->domain); + if (cwl != NULL) { + while(fgets(line, 256, cwl) != NULL) { + if (!strncmp(((SoupCookie *)p->data)->domain, + line, + sizeof(((SoupCookie *)p->data)->domain))) { + setcookie((SoupCookie *)p->data); + printf("\tAccepted cookie: %s\n", + ((SoupCookie *)p->data)->domain); + break; + } + } + } + rewind(cwl); + } + fclose(cwl); soup_cookies_free(l); } @@ -341,15 +363,17 @@ guint i; gboolean processed = FALSE; - updatewinid(c); - for(i = 0; i < LENGTH(keys); i++) { - if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval - && CLEANMASK(ev->state) == keys[i].mod - && keys[i].func) { - keys[i].func(c, &(keys[i].arg)); - processed = TRUE; + if (!webkit_web_view_can_paste_clipboard(c->view)) { + updatewinid(c); + for(i = 0; i < LENGTH(keys); i++) { + if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval + && CLEANMASK(ev->state) == keys[i].mod + && keys[i].func) { + keys[i].func(c, &(keys[i].arg)); + processed = TRUE; + } } - } + } return processed; } @@ -689,6 +713,7 @@ /* dirs and files */ cookiefile = buildpath(cookiefile); + cookiewlist = buildpath(cookiewlist); scriptfile = buildpath(scriptfile); stylefile = buildpath(stylefile);