Merge lp:~kalikiana/midori/cookiesdebug into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: André Stösel
Approved revision: 6335
Merged at revision: 6337
Proposed branch: lp:~kalikiana/midori/cookiesdebug
Merge into: lp:midori
Diff against target: 61 lines (+30/-17)
1 file modified
midori/midori-session.c (+30/-17)
To merge this branch: bzr merge lp:~kalikiana/midori/cookiesdebug
Reviewer Review Type Date Requested Status
André Stösel Approve
Review via email: mp+179571@code.launchpad.net

Commit message

Revise "cookies" debug output, merge expiry check and disallow revival of old cookies

Description of the change

Related to bug 1199445 I made the debug output for cookies actually useful by printing all values, and indeed the changes applied on the Midori side.

r6334:
Soup API uses absolute points in time. We always need to double-check if a cookie has a too long life span before trying to limit it - or we inadvertendly extend it.

r6335:
Cookies may be happily overwritten by their owner and thereby resetting the expiry. The most reliable solution is probably to lock expiry changes.

To post a comment you must log in.
lp:~kalikiana/midori/cookiesdebug updated
6334. By Cris Dywan

Merge cookie age checks for age > 0 and 0

6335. By Cris Dywan

Don't allow revival of expiring cookies

Revision history for this message
André Stösel (ivaldi) wrote :

Finally fixed, thank you.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'midori/midori-session.c'
--- midori/midori-session.c 2013-07-29 20:58:17 +0000
+++ midori/midori-session.c 2013-08-10 14:25:14 +0000
@@ -263,28 +263,41 @@
263 SoupCookie* new_cookie,263 SoupCookie* new_cookie,
264 MidoriWebSettings* settings)264 MidoriWebSettings* settings)
265{265{
266
267 if (midori_debug ("cookies"))
268 {
269 gchar* old = old_cookie ? soup_cookie_to_cookie_header (old_cookie) : NULL;
270 gchar* new = new_cookie ? soup_cookie_to_cookie_header (new_cookie) : NULL;
271 g_print ("cookie changed from %s to %s\n", old, new);
272 g_free (old);
273 g_free (new);
274 }
275
276 /* Don't allow revival of expiring cookies */
277 if (new_cookie && old_cookie && old_cookie->expires)
278 soup_cookie_set_expires (new_cookie, old_cookie->expires);
279
266 if (new_cookie && new_cookie->expires)280 if (new_cookie && new_cookie->expires)
267 {281 {
268 time_t expires = soup_date_to_time_t (new_cookie->expires);282 time_t expires = soup_date_to_time_t (new_cookie->expires);
269 gint age = katze_object_get_int (settings, "maximum-cookie-age");283 gint age = katze_object_get_int (settings, "maximum-cookie-age");
270 if (age > 0)284 /* An age of 0 to SoupCookie means already-expired
271 {285 A user choosing 0 days probably expects 1 hour.
272 SoupDate* max_date = soup_date_new_from_now (286 */
273 age * SOUP_COOKIE_MAX_AGE_ONE_DAY);287 int seconds = age > 0 ? age * SOUP_COOKIE_MAX_AGE_ONE_DAY : SOUP_COOKIE_MAX_AGE_ONE_HOUR;
274 if (soup_date_to_time_t (new_cookie->expires)288 SoupDate* max_date = soup_date_new_from_now (seconds);
275 > soup_date_to_time_t (max_date))289 if (expires > soup_date_to_time_t (max_date))
276 soup_cookie_set_expires (new_cookie, max_date);290 {
277 }291 if (midori_debug ("cookies"))
278 else292 {
279 {293 gchar* new_date = soup_date_to_string (max_date, SOUP_DATE_COOKIE);
280 /* An age of 0 to SoupCookie means already-expired294 g_print ("^^ enforcing expiry: %s\n", new_date);
281 A user choosing 0 days probably expects 1 hour. */295 g_free (new_date);
282 soup_cookie_set_max_age (new_cookie, SOUP_COOKIE_MAX_AGE_ONE_HOUR);296 }
283 }297 soup_cookie_set_expires (new_cookie, max_date);
298 }
299 soup_date_free (max_date);
284 }300 }
285
286 if (midori_debug ("cookies"))
287 g_print ("cookie changed: old %p new %p\n", old_cookie, new_cookie);
288}301}
289#endif302#endif
290303

Subscribers

People subscribed via source and target branches

to all changes: