aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2010-01-09 20:32:07 +0000
committercorvid <corvid@lavabit.com>2010-01-09 20:32:07 +0000
commiteb81bf9aff9d3add40c16ff8776fd37813819335 (patch)
tree1ced4e1016b4a9a757bce0cec45a341c4a730a28 /src
parentfed42d15a0d2358fd6766c6f0e230ef15c46795a (diff)
cookies use server date to interpret Expires attr
Diffstat (limited to 'src')
-rw-r--r--src/cache.c5
-rw-r--r--src/cookies.c14
-rw-r--r--src/cookies.h3
3 files changed, 16 insertions, 6 deletions
diff --git a/src/cache.c b/src/cache.c
index 3341388c..8700502e 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -733,10 +733,13 @@ static void Cache_parse_header(CacheEntry_t *entry)
* know if that is a real issue though. */
if ((Cookies = Cache_parse_multiple_fields(header, "Set-Cookie2")) ||
(Cookies = Cache_parse_multiple_fields(header, "Set-Cookie"))) {
- a_Cookies_set(Cookies, entry->Url);
+ char *server_date = Cache_parse_field(header, "Date");
+
+ a_Cookies_set(Cookies, entry->Url, server_date);
for (i = 0; (data = dList_nth_data(Cookies, i)); ++i)
dFree(data);
dList_free(Cookies);
+ dFree(server_date);
}
#endif /* !DISABLE_COOKIES */
diff --git a/src/cookies.c b/src/cookies.c
index 0793a670..ceb5b238 100644
--- a/src/cookies.c
+++ b/src/cookies.c
@@ -138,7 +138,8 @@ void a_Cookies_freeall()
/*
* Set the value corresponding to the cookie string
*/
-void a_Cookies_set(Dlist *cookie_strings, const DilloUrl *set_url)
+void a_Cookies_set(Dlist *cookie_strings, const DilloUrl *set_url,
+ const char *date)
{
CookieControlAction action;
char *cmd, *cookie_string, *dpip_tag;
@@ -156,9 +157,14 @@ void a_Cookies_set(Dlist *cookie_strings, const DilloUrl *set_url)
for (i = 0; (cookie_string = dList_nth_data(cookie_strings, i)); ++i) {
path = URL_PATH_(set_url);
- cmd = a_Dpip_build_cmd("cmd=%s cookie=%s host=%s path=%s",
- "set_cookie", cookie_string, URL_HOST_(set_url),
- path ? path : "/");
+ if (date)
+ cmd = a_Dpip_build_cmd("cmd=%s cookie=%s host=%s path=%s date=%s",
+ "set_cookie", cookie_string,
+ URL_HOST_(set_url), path ? path : "/", date);
+ else
+ cmd = a_Dpip_build_cmd("cmd=%s cookie=%s host=%s path=%s",
+ "set_cookie", cookie_string,
+ URL_HOST_(set_url), path ? path : "/");
_MSG("Cookies.c: a_Cookies_set \n\t \"%s\" \n",cmd );
/* This call is commented because it doesn't guarantee the order
diff --git a/src/cookies.h b/src/cookies.h
index 6f9f77e0..482aa5ae 100644
--- a/src/cookies.h
+++ b/src/cookies.h
@@ -12,7 +12,8 @@ extern "C" {
# define a_Cookies_freeall() ;
#else
char *a_Cookies_get_query(const DilloUrl *request_url);
- void a_Cookies_set(Dlist *cookie_string, const DilloUrl *set_url);
+ void a_Cookies_set(Dlist *cookie_string, const DilloUrl *set_url,
+ const char *server_date);
void a_Cookies_init( void );
void a_Cookies_freeall( void );
#endif