summaryrefslogtreecommitdiff
path: root/content/urldb.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-11-22 00:34:06 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-11-22 00:34:06 +0000
commiteb122c52d28fd8a933897b13b35da21d40a9f415 (patch)
tree063ab45d595e3260728cb4cb75117ab3b6a3d923 /content/urldb.c
parent3f395ec3bf1e439eaa95f22219fce2f6e37c292f (diff)
downloadnetsurf-eb122c52d28fd8a933897b13b35da21d40a9f415.tar.gz
netsurf-eb122c52d28fd8a933897b13b35da21d40a9f415.tar.bz2
Fix cookie expiration
svn path=/trunk/netsurf/; revision=13161
Diffstat (limited to 'content/urldb.c')
-rw-r--r--content/urldb.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/content/urldb.c b/content/urldb.c
index 67ba5701d..8053f5094 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -120,7 +120,7 @@ struct cookie_internal_data {
char *domain; /**< Domain */
bool path_from_set; /**< Path came from Set-Cookie: header */
char *path; /**< Path */
- time_t expires; /**< Expiry timestamp, or 1 for session */
+ time_t expires; /**< Expiry timestamp, or -1 for session */
time_t last_used; /**< Last used time */
bool secure; /**< Only send for HTTPS requests */
cookie_version version; /**< Specification compliance */
@@ -2505,7 +2505,7 @@ char *urldb_get_cookie(const char *url)
/* Consider all cookies associated with
* this exact path */
for (c = q->cookies; c; c = c->next) {
- if (c->expires != 1 && c->expires < now)
+ if (c->expires != -1 && c->expires < now)
/* cookie has expired => ignore */
continue;
@@ -2537,7 +2537,7 @@ char *urldb_get_cookie(const char *url)
continue;
for (c = q->cookies; c; c = c->next) {
- if (c->expires != 1 && c->expires < now)
+ if (c->expires != -1 && c->expires < now)
/* cookie has expired => ignore */
continue;
@@ -2573,7 +2573,7 @@ char *urldb_get_cookie(const char *url)
/* Consider p itself - may be the result of Path=/foo */
for (c = p->cookies; c; c = c->next) {
- if (c->expires != 1 && c->expires < now)
+ if (c->expires != -1 && c->expires < now)
/* cookie has expired => ignore */
continue;
@@ -2604,7 +2604,7 @@ char *urldb_get_cookie(const char *url)
for (h = (const struct host_part *)p; h && h != &db_root;
h = h->parent) {
for (c = h->paths.cookies; c; c = c->next) {
- if (c->expires != 1 && c->expires < now)
+ if (c->expires != -1 && c->expires < now)
/* cookie has expired => ignore */
continue;
@@ -3180,9 +3180,6 @@ struct cookie_internal_data *urldb_parse_cookie(const char *url,
c->path = path;
}
- if (c->expires == -1)
- c->expires = 1;
-
/* Write back current position */
*cookie = cur;
@@ -3308,6 +3305,7 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, const char *scheme,
struct cookie_internal_data *d;
const struct host_part *h;
struct path_data *p;
+ time_t now = time(NULL);
assert(c && scheme && url);
@@ -3355,7 +3353,7 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, const char *scheme,
}
if (d) {
- if (c->expires == 0) {
+ if (c->expires != -1 && c->expires < now) {
/* remove cookie */
if (d->next)
d->next->prev = d->prev;
@@ -3856,8 +3854,8 @@ void urldb_save_cookie_paths(FILE *fp, struct path_data *parent)
struct cookie_internal_data *c;
for (c = p->cookies; c != NULL; c = c->next) {
- if (c->expires < now)
- /* Skip expired cookies */
+ if (c->expires == -1 || c->expires < now)
+ /* Skip expired & session cookies */
continue;
fprintf(fp,