]> spindle.queued.net Git - midori/commitdiff
Improve handling of cookie updates
authorChristian Dywan <christian@twotoasts.de>
Sun, 20 Feb 2011 19:55:34 +0000 (20:55 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sun, 20 Feb 2011 19:55:34 +0000 (20:55 +0100)
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
katze/katze-http-cookies.c
midori/main.c

index 951a1c96615653e083067ac4785cd8e5a51e73e6..43379dcac385ee37cfe62a9729c7efcd9c290e72 100644 (file)
@@ -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);
index d7ceb6b2fb24ee05913286e9976c57a525d6d973..20ced5257a934de1c45bdef92388e4a3f7eb3fbe 100644 (file)
@@ -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);
     }
 }