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
1=== modified file 'midori/midori-session.c'
2--- midori/midori-session.c 2013-07-29 20:58:17 +0000
3+++ midori/midori-session.c 2013-08-10 14:25:14 +0000
4@@ -263,28 +263,41 @@
5 SoupCookie* new_cookie,
6 MidoriWebSettings* settings)
7 {
8+
9+ if (midori_debug ("cookies"))
10+ {
11+ gchar* old = old_cookie ? soup_cookie_to_cookie_header (old_cookie) : NULL;
12+ gchar* new = new_cookie ? soup_cookie_to_cookie_header (new_cookie) : NULL;
13+ g_print ("cookie changed from %s to %s\n", old, new);
14+ g_free (old);
15+ g_free (new);
16+ }
17+
18+ /* Don't allow revival of expiring cookies */
19+ if (new_cookie && old_cookie && old_cookie->expires)
20+ soup_cookie_set_expires (new_cookie, old_cookie->expires);
21+
22 if (new_cookie && new_cookie->expires)
23 {
24 time_t expires = soup_date_to_time_t (new_cookie->expires);
25 gint age = katze_object_get_int (settings, "maximum-cookie-age");
26- if (age > 0)
27- {
28- SoupDate* max_date = soup_date_new_from_now (
29- age * SOUP_COOKIE_MAX_AGE_ONE_DAY);
30- if (soup_date_to_time_t (new_cookie->expires)
31- > soup_date_to_time_t (max_date))
32- soup_cookie_set_expires (new_cookie, max_date);
33- }
34- else
35- {
36- /* An age of 0 to SoupCookie means already-expired
37- A user choosing 0 days probably expects 1 hour. */
38- soup_cookie_set_max_age (new_cookie, SOUP_COOKIE_MAX_AGE_ONE_HOUR);
39- }
40+ /* An age of 0 to SoupCookie means already-expired
41+ A user choosing 0 days probably expects 1 hour.
42+ */
43+ int seconds = age > 0 ? age * SOUP_COOKIE_MAX_AGE_ONE_DAY : SOUP_COOKIE_MAX_AGE_ONE_HOUR;
44+ SoupDate* max_date = soup_date_new_from_now (seconds);
45+ if (expires > soup_date_to_time_t (max_date))
46+ {
47+ if (midori_debug ("cookies"))
48+ {
49+ gchar* new_date = soup_date_to_string (max_date, SOUP_DATE_COOKIE);
50+ g_print ("^^ enforcing expiry: %s\n", new_date);
51+ g_free (new_date);
52+ }
53+ soup_cookie_set_expires (new_cookie, max_date);
54+ }
55+ soup_date_free (max_date);
56 }
57-
58- if (midori_debug ("cookies"))
59- g_print ("cookie changed: old %p new %p\n", old_cookie, new_cookie);
60 }
61 #endif
62

Subscribers

People subscribed via source and target branches

to all changes: