From: Christian Dywan Date: Sun, 20 Feb 2011 19:55:34 +0000 (+0100) Subject: Improve handling of cookie updates X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea8b9ee7fefe7a5a6dd52d9e429c18b571268826;p=midori Improve handling of cookie updates Be sure to remove outstanding times, use libsoup API to free the list of cookies and use the cookie jar to delete cookies. Fixes: https://bugs.launchpad.net/midori/+bug/712770 --- diff --git a/katze/katze-http-cookies.c b/katze/katze-http-cookies.c index 951a1c96..43379dca 100644 --- a/katze/katze-http-cookies.c +++ b/katze/katze-http-cookies.c @@ -178,7 +178,11 @@ katze_http_cookies_update_jar (KatzeHttpCookies* http_cookies) gchar* temporary_filename = NULL; GSList* cookies; - http_cookies->timeout = 0; + if (http_cookies->timeout > 0) + { + g_source_remove (http_cookies->timeout); + http_cookies->timeout = 0; + } temporary_filename = g_strconcat (http_cookies->filename, ".XXXXXX", NULL); if ((fn = g_mkstemp (temporary_filename)) == -1) @@ -299,7 +303,7 @@ katze_http_cookies_detach (SoupSessionFeature* feature, SoupSession* session) { KatzeHttpCookies* http_cookies = (KatzeHttpCookies*)feature; - if (http_cookies->timeout) + if (http_cookies->timeout > 0) katze_http_cookies_update_jar (http_cookies); katze_assign (http_cookies->filename, NULL); katze_object_assign (http_cookies->jar, NULL); diff --git a/midori/main.c b/midori/main.c index d7ceb6b2..20ced525 100644 --- a/midori/main.c +++ b/midori/main.c @@ -1563,18 +1563,21 @@ midori_clear_web_cookies_cb (void) SoupSession* session = webkit_get_default_session (); SoupSessionFeature* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); GSList* cookies = soup_cookie_jar_all_cookies (SOUP_COOKIE_JAR (jar)); + SoupSessionFeature* feature; + for (; cookies != NULL; cookies = g_slist_next (cookies)) { SoupCookie* cookie = cookies->data; - soup_cookie_set_max_age (cookie, 0); - soup_cookie_free (cookie); + soup_cookie_jar_delete_cookie ((SoupCookieJar*)jar, cookie); } - g_slist_free (cookies); + soup_cookies_free (cookies); /* Removing KatzeHttpCookies makes it save outstanding changes */ - if (soup_session_get_feature (session, KATZE_TYPE_HTTP_COOKIES)) + if ((feature = soup_session_get_feature (session, KATZE_TYPE_HTTP_COOKIES))) { - soup_session_remove_feature_by_type (session, KATZE_TYPE_HTTP_COOKIES); - soup_session_add_feature_by_type (session, KATZE_TYPE_HTTP_COOKIES); + g_object_ref (feature); + soup_session_remove_feature (session, feature); + soup_session_add_feature (session, feature); + g_object_unref (feature); } }